PHPackages                             galaxon/core - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. galaxon/core

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

galaxon/core
============

Core PHP utilities for floats, integers, arrays, types, and string conversion with IEEE-754 support.

v1.5.1(1mo ago)0174MITPHPPHP ^8.4

Since Dec 7Pushed 1mo agoCompare

[ Source](https://github.com/mossy2100/Galaxon-PHP-Core)[ Packagist](https://packagist.org/packages/galaxon/core)[ Docs](https://github.com/mossy2100/Galaxon-PHP-Core)[ RSS](/packages/galaxon-core/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (10)Versions (12)Used By (4)

Galaxon PHP Core
================

[](#galaxon-php-core)

A general purpose library containing core utility classes and methods for use by other Galaxon PHP packages.

**[License](LICENSE)** | **[Changelog](CHANGELOG.md)** | **[Documentation](docs/)**

[![PHP 8.4](docs/logo_php8_4.png)](docs/logo_php8_4.png)

---

Description
-----------

[](#description)

This package provides a comprehensive set of utility classes for working with various PHP types and common operations. All utility classes are final with static methods and cannot be instantiated.

---

Development and Quality Assurance / AI Disclosure
-------------------------------------------------

[](#development-and-quality-assurance--ai-disclosure)

[Claude Chat](https://claude.ai) and [Claude Code](https://www.claude.com/product/claude-code) were used in the development of this package. The core classes were designed, coded, and commented primarily by the author, with Claude providing substantial assistance with code review, suggesting improvements, debugging, and generating tests and documentation. All code was thoroughly reviewed by the author, and validated using industry-standard tools including [PHP\_Codesniffer](https://github.com/PHPCSStandards/PHP_CodeSniffer/), [PHPStan](https://phpstan.org/) (to level 9), and [PHPUnit](https://phpunit.de/index.html) to ensure full compliance with [PSR-12](https://www.php-fig.org/psr/psr-12/) coding standards and comprehensive unit testing with 100% code coverage. This collaborative approach resulted in a high-quality, thoroughly-tested, and well-documented package delivered in significantly less time than traditional development methods.

[![Code Coverage](https://camo.githubusercontent.com/32855e94577df9d0a30995653b17d33a5fbfdf644518f96ea0374313397d19b7/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f636f7665726167652d3130302532352d627269676874677265656e)](https://camo.githubusercontent.com/32855e94577df9d0a30995653b17d33a5fbfdf644518f96ea0374313397d19b7/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f636f7665726167652d3130302532352d627269676874677265656e)

---

Requirements
------------

[](#requirements)

- PHP ^8.4

---

Installation
------------

[](#installation)

```
composer require galaxon/core
```

---

Classes
-------

[](#classes)

### [Numbers](docs/Numbers.md)

[](#numbers)

General number-related utility methods including sign operations.

### [Floats](docs/Floats.md)

[](#floats)

Float-specific utilities for handling IEEE-754 special values (-0.0, ±INF, NAN), approximate comparison, float space navigation (next/previous), random generation, and IEEE-754 component assembly/disassembly.

### [Integers](docs/Integers.md)

[](#integers)

Integer arithmetic operations with overflow checking (add, subtract, multiply, power), GCD calculation, and Unicode subscript/superscript conversion.

### [Arrays](docs/Arrays.md)

[](#arrays)

Array utility methods including circular reference detection, value quoting, and first/last element extraction.

### [Types](docs/Types.md)

[](#types)

Type checking and inspection utilities with methods for identifying numbers, unsigned integers, traits, and generating unique string keys.

### [Strings](docs/Strings.md)

[](#strings)

String conversion and output utilities. Converts any value to a string, passing strings through as-is and using `__toString()` for Stringable objects.

### [Stringify](docs/Stringify.md)

[](#stringify)

Advanced value-to-string conversion with pretty printing, supporting all PHP types with improved readability.

---

Functions
---------

[](#functions)

### [Functions](docs/Functions.md)

[](#functions-1)

Convenience functions in the `Galaxon\Core` namespace, including `println()` for outputting strings and other values.

---

Traits
------

[](#traits)

### Comparison Traits

[](#comparison-traits)

Equality and ordering comparison operations for custom types. See [ComparisonTraits.md](docs/Traits/Comparison/ComparisonTraits.md) for the trait hierarchy and usage guide.

TraitDescription[Equatable](docs/Traits/Comparison/Equatable.md)Base trait for exact equality comparison via `equal()`.[Comparable](docs/Traits/Comparison/Comparable.md)Extends Equatable with ordering: `lessThan()`, `greaterThan()`, etc.[ApproxEquatable](docs/Traits/Comparison/ApproxEquatable.md)Extends Equatable with tolerance-based `approxEqual()`.[ApproxComparable](docs/Traits/Comparison/ApproxComparable.md)Combines Comparable and ApproxEquatable with `approxCompare()`.### Assert Traits

[](#assert-traits)

Custom PHPUnit assertions for test cases. See [TestingTraits.md](docs/Traits/Asserts/TestingTraits.md) for usage examples.

TraitDescription[FloatAssertions](docs/Traits/Asserts/FloatAssertions.md)Provides `assertApproxEqual()` and `assertApproxZero()` with informative failure messages.---

Exceptions
----------

[](#exceptions)

### [IncomparableTypesException](docs/Exceptions/IncomparableTypesException.md)

[](#incomparabletypesexception)

Exception thrown when attempting to compare values of incompatible types. Used by the Comparable and ApproxComparable traits. Automatically generates descriptive error messages.

### [FormatException](docs/Exceptions/FormatException.md)

[](#formatexception)

Exception thrown when a string has an invalid format for the desired operation. Extends `DomainException`. Useful for parse methods or constructors that accept string arguments.

---

Testing
-------

[](#testing)

The library includes comprehensive test coverage:

```
# Run all tests
vendor/bin/phpunit

# Run specific test class
vendor/bin/phpunit tests/NumbersTest.php

# Run with coverage (generates HTML report and clover.xml)
composer test
```

---

License
-------

[](#license)

MIT License - see [LICENSE](LICENSE) for details

---

Support
-------

[](#support)

- **Issues**:
- **Documentation**: See [docs/](docs/) directory for detailed class documentation
- **Examples**: See test files for comprehensive usage examples

For questions or suggestions, please [open an issue](https://github.com/mossy2100/Galaxon-PHP-Core/issues).

---

Changelog
---------

[](#changelog)

See [CHANGELOG.md](CHANGELOG.md) for version history and changes.

###  Health Score

45

—

FairBetter than 93% of packages

Maintenance91

Actively maintained with recent releases

Popularity8

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~11 days

Total

11

Last Release

47d ago

Major Versions

v0.6.0 → v1.0.02026-01-04

### Community

Maintainers

![](https://www.gravatar.com/avatar/6f9cd1bb5c1b12882db4cb82161c1b5a22e1ccbad8845a54a6ae591647e88c07?d=identicon)[mossy2100](/maintainers/mossy2100)

---

Top Contributors

[![mossy2100](https://avatars.githubusercontent.com/u/371497?v=4)](https://github.com/mossy2100 "mossy2100 (78 commits)")

---

Tags

phpstringifymathutilitiesnumbersarraystraitstypescomparablefloatsintegersequatableieee-754

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/galaxon-core/health.svg)

```
[![Health](https://phpackages.com/badges/galaxon-core/health.svg)](https://phpackages.com/packages/galaxon-core)
```

###  Alternatives

[ilya/belt

A handful of tools for PHP developers.

71020.8k1](/packages/ilya-belt)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
