PHPackages                             alecrabbit/php-accessories - 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. alecrabbit/php-accessories

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

alecrabbit/php-accessories
==========================

PHP Accessories: Classes etc.

0.14.0(6y ago)04.2k2MITPHPPHP &gt;=7.2CI passing

Since Dec 14Pushed 5y ago1 watchersCompare

[ Source](https://github.com/alecrabbit/php-accessories)[ Packagist](https://packagist.org/packages/alecrabbit/php-accessories)[ RSS](/packages/alecrabbit-php-accessories/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependencies (6)Versions (29)Used By (2)

PHP accessories
===============

[](#php-accessories)

[![PHP Version](https://camo.githubusercontent.com/ade15067057059448eefac262666b396a8cc4cef86b8b208fee3fa3658aea90a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f616c65637261626269742f7068702d6163636573736f726965732e737667)](https://php.net)[![Build Status](https://camo.githubusercontent.com/91daca0d5ac1d4674cc461db390e8f22b56dbd0b04b788ef4b9c1cacbcf06600/68747470733a2f2f7472617669732d63692e6f72672f616c65637261626269742f7068702d6163636573736f726965732e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/alecrabbit/php-accessories)[![Appveyor Status](https://camo.githubusercontent.com/f2743963ac3caa7711abc10af2a25ee7a3b5966598444efbf45b6203d5006d16/68747470733a2f2f696d672e736869656c64732e696f2f6170707665796f722f63692f616c65637261626269742f7068702d6163636573736f726965732e7376673f6c6162656c3d6170707665796f72)](https://ci.appveyor.com/project/alecrabbit/php-accessories/branch/master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/8461bf6b65c489ae363443cabe71b3cc97735c26f95032d47226e847ab6ecbb0/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f616c65637261626269742f7068702d6163636573736f726965732f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/alecrabbit/php-accessories/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/e45c5144cd33a88b752b1d4aec2b7cc61338b0920799f715612b64d3249663c9/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f616c65637261626269742f7068702d6163636573736f726965732f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/alecrabbit/php-accessories/?branch=master)[![Total Downloads](https://camo.githubusercontent.com/13eb06b561fd1f8973a8b05f630b4836659c52e0ae050f7b8ad69dc34a8f9a77/68747470733a2f2f706f7365722e707567782e6f72672f616c65637261626269742f7068702d6163636573736f726965732f646f776e6c6f616473)](https://packagist.org/packages/alecrabbit/php-accessories)

[![Latest Stable Version](https://camo.githubusercontent.com/01536879be3c0a6e3b832f8a741f4aa306ecca872fcb4ecac1dca90da5cb36f3/68747470733a2f2f706f7365722e707567782e6f72672f616c65637261626269742f7068702d6163636573736f726965732f762f737461626c65)](https://packagist.org/packages/alecrabbit/php-accessories)[![Latest Stable Version](https://camo.githubusercontent.com/ab1d179aa12bbdde2e0322a54fc5ebddcd09dcb0ea1c6d3629754d1d07329189/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f616c65637261626269742f7068702d6163636573736f726965732e737667)](https://packagist.org/packages/alecrabbit/php-accessories)[![Latest Unstable Version](https://camo.githubusercontent.com/3fb7b5ff3ac5e5c375f8e57bfc792bbf569bbb9fb6dbd19020a485c2c94267ab/68747470733a2f2f706f7365722e707567782e6f72672f616c65637261626269742f7068702d6163636573736f726965732f762f756e737461626c65)](https://packagist.org/packages/alecrabbit/php-accessories)

[![License](https://camo.githubusercontent.com/d389015a99216f8094522507c0963af9eef617ce8ba6e9a4df2afdd809c47a15/68747470733a2f2f706f7365722e707567782e6f72672f616c65637261626269742f7068702d6163636573736f726965732f6c6963656e7365)](https://packagist.org/packages/alecrabbit/php-accessories)[![Average time to resolve an issue](https://camo.githubusercontent.com/d259b882cb621aa9b726c3627a9a986175e4a48b50c44aa39e80dd3b1f7ef88a/687474703a2f2f697369746d61696e7461696e65642e636f6d2f62616467652f7265736f6c7574696f6e2f616c65637261626269742f7068702d6163636573736f726965732e737667)](http://isitmaintained.com/project/alecrabbit/php-accessories "Average time to resolve an issue")[![Percentage of issues still open](https://camo.githubusercontent.com/85e1323ad07d7e594fc12d8d6ce3e809516d9190f394d9999a98e6f030cd8811/687474703a2f2f697369746d61696e7461696e65642e636f6d2f62616467652f6f70656e2f616c65637261626269742f7068702d6163636573736f726965732e737667)](http://isitmaintained.com/project/alecrabbit/php-accessories "Percentage of issues still open")

### Installation

[](#installation)

```
composer require alecrabbit/php-accessories
```

### Usage

[](#usage)

for details see [examples](https://github.com/alecrabbit/php-accessories/tree/master/examples)

### Features

[](#features)

##### Caller::class

[](#callerclass)

Gets a caller `Class::method()` or `function()` or `Undefined`

```
$caller = Caller::get() // object(AlecRabbit\Accessories\Caller\CallerData)
```

> Note: `CallerData::class` can be casted to string

```
if($wrongArguments) {
 throw new \RuntimeException(Caller::get() . ' provided wrong arguments');
}
```

You can set your custom formatter for string casting:

```
$formatter = new CustomFormatter($options);
Caller::setFormatter($formatter);
```

> Note: `CustomFormatter::class` should implement `CallerDataFormatterInterface`

##### Circular::class

[](#circularclass)

Helper class to get values in a circle

```
$c = new Circular([1, 2, 3]);
$value = $c(); // int(1) invoke
$value = $c->value(); // int(2) get value by method
...
$c(); // int(3)
...
$c(); // int(1)
```

> Note: `Circular::__construct` can accept `array`, `Rewindable` or callable which returns `\Generator`

##### Rewindable::class

[](#rewindableclass)

Rewindable generator helper class

```
$r = new Rewindable($genFunc); // $genFunc is a callable and returns \Generator
iterator_to_array($r);
$r->rewind();
```

##### G::class

[](#gclass)

Contains generator functions

```
$r = G::range(1, 3);  // object(Generator)
```

##### R::class

[](#rclass)

Contains rewindable generator functions

```
$r = R::range(1, 3); // object(AlecRabbit\Accessories\Rewindable)
iterator_to_array($r);
$r->rewind();
```

##### Pretty::class

[](#prettyclass)

String formatter, e.g. percent, bytes and time(seconds, microseconds, nanoseconds)

```
Pretty::bytes(10584760, 'mb'); // string(7) "10.09MB"
Pretty::time(0.214); // string(5) "214ms"
Pretty::percent(0.214);  // string(6) "21.40%"

Pretty::seconds(0.214); // string(5) "214ms"

Pretty::milliseconds(214); // string(5) "214ms"

Pretty::useconds(3212); // string(5) "3.2ms"
Pretty::useconds(12); // string(5) "12μs"
// alias for useconds
Pretty::microseconds(12); // string(5) "12μs"

Pretty::nanoseconds(10485); // string(7) "10.5μs"
Pretty::nanoseconds(105); // string(7) "105ns"
```

> Note: time formatting methods of `Pretty::class` named by units they are accepting

##### MemoryUsage::class

[](#memoryusageclass)

Helper class to get memory usage

```
$report = MemoryUsage::reportStatic('mb');
echo $report . PHP_EOL;
// Memory: 0.75MB(32.73MB) Real: 2.00MB(34.00MB)
```

You can set your custom formatter for string casting:

```
$formatter = new CustomFormatter($options);
MemoryUsage::setFormatter($formatter);
```

> Note: `CustomFormatter::class` should implement `MemoryUsageReportFormatterInterface`

> Note: Parameter `$options` has no effect on `MemoryUsageReportFormatter`

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 99.6% 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 ~12 days

Recently: every ~18 days

Total

26

Last Release

2455d ago

PHP version history (2 changes)0.0.17PHP &gt;=7.2

0.4.3PHP ^7.2

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/11045453?v=4)[Alec](/maintainers/alecrabbit)[@alecrabbit](https://github.com/alecrabbit)

---

Top Contributors

[![alecrabbit](https://avatars.githubusercontent.com/u/11045453?v=4)](https://github.com/alecrabbit "alecrabbit (282 commits)")[![dependabot-preview[bot]](https://avatars.githubusercontent.com/in/2141?v=4)](https://github.com/dependabot-preview[bot] "dependabot-preview[bot] (1 commits)")

---

Tags

arraygeneratortimeiteratorprettyrangebytespercentmemory\_usagecircularcallerrewindable

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/alecrabbit-php-accessories/health.svg)

```
[![Health](https://phpackages.com/badges/alecrabbit-php-accessories/health.svg)](https://phpackages.com/packages/alecrabbit-php-accessories)
```

###  Alternatives

[athari/yalinqo

YaLinqo, a LINQ-to-objects library for PHP

4531.2M5](/packages/athari-yalinqo)[nikic/iter

Iteration primitives using generators

1.1k6.2M51](/packages/nikic-iter)[league/period

Time range API for PHP

7335.7M22](/packages/league-period)[loophp/collection

A (memory) friendly, easy, lazy and modular collection class.

743730.3k15](/packages/loophp-collection)[ihor/nspl

Non-standard PHP library (NSPL) - functional primitives toolbox and more

375369.1k](/packages/ihor-nspl)[consistence/consistence

Consistence - consistent approach and additions to PHP's functionality

1821.1M18](/packages/consistence-consistence)

PHPackages © 2026

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