PHPackages                             phrity/o - 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. [Queues &amp; Workers](/categories/queues)
4. /
5. phrity/o

ActiveLibrary[Queues &amp; Workers](/categories/queues)

phrity/o
========

Consistent object representation of data types. Inheritance friendly implementation. Provides wrapper classes for array, object, string, float, int and bool, plus Queue and Stack collections.

2.1.1(5mo ago)048MITPHPPHP ^8.1CI passing

Since Apr 17Pushed 5mo ago1 watchersCompare

[ Source](https://github.com/sirn-se/phrity-o)[ Packagist](https://packagist.org/packages/phrity/o)[ Docs](https://phrity.sirn.se/o)[ RSS](/packages/phrity-o/feed)WikiDiscussions main Synced 3d ago

READMEChangelog (5)Dependencies (5)Versions (11)Used By (0)

[![Build Status](https://github.com/sirn-se/phrity-o/actions/workflows/acceptance.yml/badge.svg)](https://github.com/sirn-se/phrity-o/actions)[![Coverage Status](https://camo.githubusercontent.com/97511a2e3604d347cb2ffb10db20864d0d8fc94698411a8037dcfb378b934e66/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f7369726e2d73652f7068726974792d6f2f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/sirn-se/phrity-o?branch=master)

O
=

[](#o)

Consistent object representation of data types.

Contains a number of traits that provide interface implementation and other functionality. These traits can be included in any class that require supported functionality.

Also provides ready-made wrapper classes for array, object, string, float, int and bool, plus Queue and Stack collections. Inheritance friendly implementation.

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

[](#installation)

Install with [Composer](https://getcomposer.org/);

```
composer require phrity/o

```

Content by source type
----------------------

[](#content-by-source-type)

- [Array](docs/Array.md) classes and traits
- [Boolean](docs/Boolean.md) class and traits
- [Integer](docs/Integer.md) class and traits
- [Number](docs/Number.md) class and traits
- [Object](docs/Number.md) class and traits
- [String](docs/String.md) class and traits

Factory
-------

[](#factory)

The [factory class](docs/Factory.md) converts scalars, arrays and objects into corresponding "O" instance.

```
$factory = new Factory();
$instance = $factory->convert([1, 2, 3]); // -> Arr instance
```

Classes
-------

[](#classes)

The following ready-made classes are available.

ClassSourceImplements[Arr](docs/Array/Arr.md)`array`[ArrayAccess](https://www.php.net/manual/en/class.arrayaccess.php) [Comparable](https://github.com/sirn-se/phrity-comparison) [Countable](https://www.php.net/manual/en/class.countable.php) [Equalable](https://github.com/sirn-se/phrity-comparison) [Iterator](https://www.php.net/manual/en/class.iterator.php) [JsonSerializable](docs/Array/JsonSerializable.md) [Stringable](https://www.php.net/manual/en/class.stringable) [Traversable](https://www.php.net/manual/en/class.traversable.php)[Boolean](docs/Boolean/Boolean.md)`bool`[Comparable](https://github.com/sirn-se/phrity-comparison) [Equalable](https://github.com/sirn-se/phrity-comparison) [Stringable](https://www.php.net/manual/en/class.stringable)[Integer](docs/Integer/Integer.md)`int`[Comparable](https://github.com/sirn-se/phrity-comparison) [Equalable](https://github.com/sirn-se/phrity-comparison) [Stringable](https://www.php.net/manual/en/class.stringable)[Number](docs/Number/Number.md)`float`[Comparable](https://github.com/sirn-se/phrity-comparison) [Equalable](https://github.com/sirn-se/phrity-comparison) [Stringable](https://www.php.net/manual/en/class.stringable)[Obj](docs/Object/Obj.md)`object`[Comparable](https://github.com/sirn-se/phrity-comparison) [Equalable](https://github.com/sirn-se/phrity-comparison) [IteratorAggregate](https://www.php.net/manual/en/class.iteratoraggregate) [JsonSerializable](docs/Object/JsonSerializable.md) [Stringable](https://www.php.net/manual/en/class.stringable) [Traversable](https://www.php.net/manual/en/class.traversable.php)[Stack](docs/Array/Stack.md)`array`[Comparable](https://github.com/sirn-se/phrity-comparison) [Countable](https://www.php.net/manual/en/class.countable.php) [Equalable](https://github.com/sirn-se/phrity-comparison) [IteratorAggregate](https://www.php.net/manual/en/class.iteratoraggregate) [Stringable](https://www.php.net/manual/en/class.stringable) [Traversable](https://www.php.net/manual/en/class.traversable.php)[Str](docs/String/Str.md)`string`[Comparable](https://github.com/sirn-se/phrity-comparison) [Equalable](https://github.com/sirn-se/phrity-comparison) [Stringable](https://www.php.net/manual/en/class.stringable)[Queue](docs/Array/Queue.md)`array`[Comparable](https://github.com/sirn-se/phrity-comparison) [Countable](https://www.php.net/manual/en/class.countable.php) [Equalable](https://github.com/sirn-se/phrity-comparison) [IteratorAggregate](https://www.php.net/manual/en/class.iteratoraggregate) [Stringable](https://www.php.net/manual/en/class.stringable) [Traversable](https://www.php.net/manual/en/class.traversable.php)Traits
------

[](#traits)

Traits are defined by source type. The following traits are available.

TraitProvidesBy source typeArrayAccessTrait[ArrayAccess](https://www.php.net/manual/en/class.arrayaccess.php)[Array](docs/Array/ArrayAccessTrait.md)CoercionTrait[Array](docs/Array/CoercionTrait.md) [Boolean](docs/Boolean/CoercionTrait.md) [Integer](docs/Integer/CoercionTrait.md) [Number](docs/Number/CoercionTrait.md) [Object](docs/Object/CoercionTrait.md) [String](docs/String/CoercionTrait.md)ComparableTrait[Comparable](https://github.com/sirn-se/phrity-comparison) [Equalable](https://github.com/sirn-se/phrity-comparison)[Array](docs/Array/ComparableTrait.md) [Boolean](docs/Boolean/ComparableTrait.md) [Integer](docs/Integer/ComparableTrait.md) [Number](docs/Number/ComparableTrait.md) [Object](docs/Object/ComparableTrait.md) [String](docs/String/ComparableTrait.md)CountableTrait[Countable](https://www.php.net/manual/en/class.countable.php)[Array](docs/Array/CountableTrait.md)InvokableTrait[Boolean](docs/Boolean/InvokableTrait.md) [Integer](docs/Integer/InvokableTrait.md) [Number](docs/Number/InvokableTrait.md) [String](docs/String/InvokableTrait.md)IteratorAggregateTrait[IteratorAggregate](https://www.php.net/manual/en/class.iteratoraggregate) [Traversable](https://www.php.net/manual/en/class.traversable.php)[Array](docs/Array/IteratorAggregateTrait.md) [Object](docs/Object/IteratorAggregateTrait.md)IteratorTrait[Iterator](https://www.php.net/manual/en/class.iterator.php) [Traversable](https://www.php.net/manual/en/class.traversable.php)[Array](docs/Array/IteratorTrait.md)JsonSerializableTrait[JsonSerializable](https://www.php.net/manual/en/jsonserializable.jsonserialize.php)[Array](docs/Array/JsonSerializable.md) [Object](docs/Object/JsonSerializable.md)PropertyAccessTrait[Object](docs/Object/PropertyAccessTrait.md)QueueIteratorTrait[IteratorAggregate](https://www.php.net/manual/en/class.iteratoraggregate) [Traversable](https://www.php.net/manual/en/class.traversable.php)[Array](docs/Array/QueueIteratorTrait.md)QueueTrait[Array](docs/Array/QueueTrait.md)StackIteratorTrait[IteratorAggregate](https://www.php.net/manual/en/class.iteratoraggregate) [Traversable](https://www.php.net/manual/en/class.traversable.php)[Array](docs/Array/StackIteratorTrait.md)StackTrait[Array](docs/Array/StackTrait.md)StringableTrait[Stringable](https://www.php.net/manual/en/class.stringable)[Array](docs/Array/StringableTrait.md) [Boolean](docs/Boolean/StringableTrait.md) [Integer](docs/Integer/StringableTrait.md) [Number](docs/Number/StringableTrait.md) [Object](docs/Object/StringableTrait.md) [String](docs/String/StringableTrait.md)TypeTrait[Array](docs/Array/TypeTrait.md) [Boolean](docs/Boolean/TypeTrait.md) [Integer](docs/Integer/TypeTrait.md) [Number](docs/Number/TypeTrait.md) [Object](docs/Object/TypeTrait.md) [String](docs/String/TypeTrait.md)Examples
--------

[](#examples)

Brief examples of classes below.

### Scalar types

[](#scalar-types)

```
$str = new Str('hello world');
$str(); // Getter
$str('world'); // Setter

$int = new Integer(1234);
$int(); // Getter
$int(5678); // Setter

$num = new Number(12.34);
$num(); // Getter
$num(56.78); // Setter

$bool = new Boolean(true);
$bool(); // Getter
$bool(false); // Setter
```

### Complex types

[](#complex-types)

```
$array = new Arr([1, 2, 3]);
$array[] = 7; // ArrayAccess support
count($array); // Countable support
foreach ($array as $key => $value) {} // Iterator support
$array->equals(new Arr([2, 3, 4])); // Comparison support

$object = new Obj(['a' => 1, 'b' => 2, 'c' => 3]);
$object->b = 5; // Property access
$object->equals(new Obj(['c' => 1, 'd' => 2])); // Comparison support
```

### Collection types

[](#collection-types)

```
$queue = new Queue([1, 2, 3]);
$queue->enqueue(4);
$queue->dequeue();
count($queue); // Countable support
foreach ($queue as $key => $item) {} // Consuming iterator support
$queue->equals(new Queue([2, 3, 4])); // Comparison support

$stack = new Stack([1, 2, 3]);
$stack->push(4);
$stack->pop();
count($stack); // Countable support
foreach ($stack as $key => $item) {} // Consuming iterator support
$stack->equals(new Stack([2, 3, 4])); // Comparison support
```

Versions
--------

[](#versions)

VersionPHP`2.1``^8.0`JsonSerializable, improved ArrayAccess and PropertyAccess`2.0``^8.0`Implementation as Traits`1.5``^8.0`Fix for PHP 8.x versions`1.4``^7.1|^8.0``1.3``^7.1``Queue` and `Stack` collection classes`1.2``^7.1``Str` (string), `Number` (float), `Integer` (int) and `Boolean` (bool) classes`1.1``>=5.6`Comparison support`1.0``>=5.6``Arr` (array) and `Obj` (object) classes

###  Health Score

44

—

FairBetter than 92% of packages

Maintenance72

Regular maintenance activity

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity75

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 ~269 days

Recently: every ~453 days

Total

10

Last Release

161d ago

Major Versions

1.5.0 → 2.0.02023-01-28

PHP version history (5 changes)1.0.0PHP &gt;=5.6

1.2.0PHP ^7.1

1.4.0PHP ^7.1|^8.0

1.5.0PHP ^8.0

2.1.1PHP ^8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/7a1a8136f4e18a0c9aa27d3c05d2cb3782ccd14c17b567e8813c41937d6deaba?d=identicon)[sirn-se](/maintainers/sirn-se)

---

Top Contributors

[![sirn-se](https://avatars.githubusercontent.com/u/4255391?v=4)](https://github.com/sirn-se "sirn-se (66 commits)")

---

Tags

arraybooleannumberobjectphpphp-libraryqueuestackstringarrayobjectqueuestack

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/phrity-o/health.svg)

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

###  Alternatives

[ramsey/collection

A PHP library for representing and manipulating collections.

1.2k486.0M69](/packages/ramsey-collection)[php-amqplib/php-amqplib

Formerly videlalvaro/php-amqplib. This library is a pure PHP implementation of the AMQP protocol. It's been tested against RabbitMQ.

4.6k125.3M879](/packages/php-amqplib-php-amqplib)[queue-interop/queue-interop

Promoting the interoperability of MQs objects. Based on Java JMS

48030.5M87](/packages/queue-interop-queue-interop)[phootwork/collection

The phootwork library fills gaps in the php language and provides better solutions than the existing ones php offers.

3924.8M15](/packages/phootwork-collection)[apinstein/jqjobs

Async job manager for PHP.

3220.2k](/packages/apinstein-jqjobs)

PHPackages © 2026

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