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.6.0(4mo ago)0214MITPHPPHP ^8.4

Since Dec 7Pushed 1w 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 2mo ago

READMEChangelogDependencies (15)Versions (13)Used By (4)

OceanMoon PHP Core
==================

[](#oceanmoon-php-core)

A general purpose package containing core PHP utility classes and methods for use by other OceanMoon 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. Most utility classes are final with static methods and cannot be instantiated directly. `Console` is the exception — a singleton with instance methods and internal style state, accessed via `Console::getInstance()`.

---

Development and Quality Assurance
---------------------------------

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

[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 has produced a well-designed, production-ready package with thorough test coverage and documentation.

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

---

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

[](#requirements)

- PHP ^8.4

---

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

[](#installation)

```
composer require oceanmoon/core
```

---

Classes
-------

[](#classes)

### [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.

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

[](#numbers)

Number-related utilities for type checking (distinguishing actual numbers from numeric strings), exact equality that correctly handles mixed int/float comparisons, and sign operations with IEEE-754 signed zero support.

### [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.

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

[](#stringify)

Advanced value-to-string conversion with pretty printing, supporting all PHP types with improved readability. This class serves as the basis of the `Console::dump()` method.

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

[](#environment)

Runtime environment detection: 64-bit architecture checks, and locale detection from the HTTP `Accept-Language` header.

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

[](#console)

Singleton for ANSI/SGR-styled console output: 16-color foreground/background, text attributes (bold, italic, underline, etc.), method chaining, style snapshot/restore, and higher-level helpers like `dump()` and severity-colored messages (`success()`, `error()`, `warn()`, `info()`).

---

[Globals](docs/Globals.md)
--------------------------

[](#globals)

Useful constants (`M_TAU`, `RECURSION`) that work better as globals (namespaced to `OceanMoon\Core`) than as class members.

---

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()` with informative failure messages.---

Enums
-----

[](#enums)

### [FloatFormat](docs/Enums/FloatFormat.md)

[](#floatformat)

Notation styles for `Floats::format()` — fixed-point, scientific, or automatic selection between the two.

### [ExponentFormat](docs/Enums/ExponentFormat.md)

[](#exponentformat)

Rendering styles for the exponent portion of scientific-notation float output, from plain ASCII `e`/`E` through to Unicode and HTML mathematical notation.

---

Exceptions
----------

[](#exceptions)

### [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.

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

[](#arithmeticexception)

Exception thrown when an arithmetic operation has no defined result for the given operands, such as division by zero or a logarithm of a non-positive number. Extends `DomainException`. Displaces `DivisionByZeroError` for userland arithmetic code in value types like `Complex`, `Rational`, `Vector`, and `Matrix`.

---

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/PHP-Core/issues).

---

Changelog
---------

[](#changelog)

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

###  Health Score

44

—

FairBetter than 90% of packages

Maintenance89

Actively maintained with recent releases

Popularity6

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity60

Established project with proven stability

 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

Recently: every ~17 days

Total

12

Last Release

132d 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 (116 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.9k1](/packages/ilya-belt)

PHPackages © 2026

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