PHPackages                             krugozor/cover - 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. krugozor/cover

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

krugozor/cover
==============

PHP Array Object (PHP collection)

v1.0.1(3mo ago)06MITPHPPHP &gt;=8.0CI passing

Since Jan 31Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/Vasiliy-Makogon/PHP-Collection)[ Packagist](https://packagist.org/packages/krugozor/cover)[ RSS](/packages/krugozor-cover/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (3)Used By (0)

[![Cover Array](docs/logo.jpg)](docs/logo.jpg)

**Other languages:**

- [Русская документация](docs/README_ru.md)
- [Documentation française](docs/README_fr.md)
- [Deutsche Dokumentation](docs/README_de.md)
- [Documentazione italiana](docs/README_it.md)
- [日本語ドキュメント](docs/README_jp.md)
- [Documentación en español](docs/README_es.md)
- [한국어 문서](docs/README_kr.md)
- [简体中文文档](docs/README_cn.md)
- [繁體中文文件](docs/README_tw.md)
- [Dokumentasi Bahasa Indonesia](docs/README_id.md)
- [Documentação em Português (BR)](docs/README_br.md)
- [हिंदी दस्तावेज़](docs/README_hi.md)
- [التوثيق بالعربية](docs/README_ar.md)
- [Türkçe Dokümantasyon](docs/README_tr.md)
- [Tài liệu tiếng Việt](docs/README_vi.md)

---

State
-----

[](#state)

### Test Status

[](#test-status)

PHP VersionStatus8.0[![PHP 8.0](https://github.com/Vasiliy-Makogon/PHP-Collection/actions/workflows/php80.yml/badge.svg)](https://github.com/Vasiliy-Makogon/PHP-Collection/actions/workflows/php80.yml)8.1[![PHP 8.1](https://github.com/Vasiliy-Makogon/PHP-Collection/actions/workflows/php81.yml/badge.svg)](https://github.com/Vasiliy-Makogon/PHP-Collection/actions/workflows/php81.yml)8.2[![PHP 8.2](https://github.com/Vasiliy-Makogon/PHP-Collection/actions/workflows/php82.yml/badge.svg)](https://github.com/Vasiliy-Makogon/PHP-Collection/actions/workflows/php82.yml)8.3[![PHP 8.3](https://github.com/Vasiliy-Makogon/PHP-Collection/actions/workflows/php83.yml/badge.svg)](https://github.com/Vasiliy-Makogon/PHP-Collection/actions/workflows/php83.yml)8.4[![PHP 8.4](https://github.com/Vasiliy-Makogon/PHP-Collection/actions/workflows/php84.yml/badge.svg)](https://github.com/Vasiliy-Makogon/PHP-Collection/actions/workflows/php84.yml)8.5[![PHP 8.5](https://github.com/Vasiliy-Makogon/PHP-Collection/actions/workflows/php85.yml/badge.svg)](https://github.com/Vasiliy-Makogon/PHP-Collection/actions/workflows/php85.yml)### Code Coverage

[](#code-coverage)

[![codecov](https://camo.githubusercontent.com/62f6261261c030af9a1294a9f0543130284316497b3eeeccc6856625430004a3/68747470733a2f2f636f6465636f762e696f2f67682f566173696c69792d4d616b6f676f6e2f5048502d436f6c6c656374696f6e2f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/Vasiliy-Makogon/PHP-Collection)

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

[](#requirements)

PHP &gt;= 8.0

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

[](#installation)

```
composer require krugozor/cover

```

CoverArray: Object-Oriented Array Wrapper for PHP (PHP Collection)
==================================================================

[](#coverarray-object-oriented-array-wrapper-for-php-php-collection)

Created by human, verified and tested by artificial intelligence. Release 2026

Why CoverArray Was Created
--------------------------

[](#why-coverarray-was-created)

In modern PHP development, we often work with arrays as the primary data structure. However, PHP's native array functions have several limitations that CoverArray solves.

### The Problem with Native PHP Arrays

[](#the-problem-with-native-php-arrays)

- **Inconsistent function naming**: Some functions use underscores (`array_map`), others don't (`usort`)
- **Mixed parameter orders**: Functions like `array_map($callback, $array)` vs `array_filter($array, $callback)`
- **No method chaining**: Native functions return new arrays, requiring intermediate variables
- **Limited type safety**: No IDE autocompletion or static analysis support
- **Verbose syntax**: Complex operations require nested function calls

### What CoverArray Solves

[](#what-coverarray-solves)

CoverArray provides a clean, object-oriented interface that wraps PHP arrays while maintaining full compatibility with native functions:

```
// Data: users with age and status
// Task: get names of active users over 18, sorted by descending score
$users = [
    ['name' => 'Alice', 'age' => 25, 'active' => true, 'score' => 85],
    ['name' => 'Bob', 'age' => 17, 'active' => false, 'score' => 45],
    ['name' => 'Charlie', 'age' => 32, 'active' => true, 'score' => 92],
    ['name' => 'Diana', 'age' => 19, 'active' => true, 'score' => 78],
    ['name' => 'Eve', 'age' => 22, 'active' => false, 'score' => 61],
];
```

#### Before (Native PHP):

[](#before-native-php)

```
$filtered = array_filter($users, fn($u) => $u['active'] && $u['age'] >= 18);
$sorted = usort($filtered, fn($a, $b) => $b['score']  $a['score']) ? $filtered : [];
$names = array_column($sorted, 'name');
$result = implode(', ', $names); // Charlie, Alice, Diana
```

#### After (CoverArray):

[](#after-coverarray)

```
// EVERYTHING IN ONE LINE!
$result = CoverArray::fromArray($users)
    ->filter(fn($u) => $u->active && $u->age >= 18)
    ->usort(fn($a, $b) => $b->score  $a->score)
    ->values()
    ->column('name')
    ->implode(', '); // Charlie, Alice, Diana
```

### Key Benefits

[](#key-benefits)

- **No External Dependencies:** Pure PHP implementation, no additional packages required
- **Consistent API:** All methods follow `$array->method($arguments)` pattern
- **Method Chaining:** Chain multiple operations in a readable way
- **IDE Support:** Full autocompletion and type hints
- **Modern Syntax:** Designed for PHP 8.0+ with strict typing
- **Dot Notation:** Easy nested data access with `$array->get('user.profile.name')`
- **JSON Support:** Built-in serialization/deserialization
- **Immutable Operations:** Most methods return new instances, preserving original data
- **Full Compatibility:** Works seamlessly with existing array-based code

### Real-World Use Cases

[](#real-world-use-cases)

#### Example 1: Configuration Management with Dot Notation

[](#example-1-configuration-management-with-dot-notation)

```
// Load and access nested configuration safely
$config = CoverArray::fromJson(file_get_contents('config.json'));

// Direct nested access with default fallbacks
$dbHost = $config->get('database.connections.mysql.host', fn($value) => $value ?? 'localhost');
$dbPort = $config->get('database.connections.mysql.port', fn($value) => $value ?? 3306);

// Access with callback for complex defaults
$apiKeys = $config->get('services.payment.keys', function($keys) {
    return $keys ?? CoverArray::fromArray([
        'public' => 'default_public_key',
        'secret' => 'default_secret_key'
    ]);
});
```

#### Example 2: API Response Processing Pipeline

[](#example-2-api-response-processing-pipeline)

```
// Real-world API processing: filter, transform, and extract data
$apiResponse = CoverArray::fromJson($httpResponse)
    ->get('data.users', function (mixed $users): CoverArray {
        if ($users === null) {
            return new CoverArray();
        }

        /** @var CoverArray $users */
        return $users
            ->filter(fn($u) => $u['active'] == '1' && $u['email_verified'])
            ->map(fn($u) => [
                'id' => $u['id'],
                'name' => $u['first_name'] . ' ' . $u['last_name'],
                'email' => strtolower($u['email']),
                'role' => $u['role'] ?? 'user'
            ])
            ->usort(fn($a, $b) => $a['name']  $b['name']);
    });

// Extract specific columns for dropdown
$userOptions = $apiResponse->column('name', 'id')->getDataAsArray();
```

#### Example 3: Log Analysis and Error Reporting

[](#example-3-log-analysis-and-error-reporting)

```
// Parse application logs and extract error patterns
$logLines = CoverArray::fromExplode("\n", file_get_contents('app.log'))
    ->filter(fn($line) => !empty(trim($line)));

// Extract and categorize errors
$errors = $logLines
    ->filter(fn($line) => str_contains($line, 'ERROR'))
    ->map(function($line) {
        preg_match('/\[(.*?)\].*ERROR:\s*(\w+)\s*-\s*(.*)/', $line, $matches);
        return [
            'timestamp' => $matches[1] ?? 'Unknown',
            'type' => $matches[2] ?? 'General',
            'message' => $matches[3] ?? $line
        ];
    });

// Group by error type and count occurrences
$errorStats = $errors
    ->column('type')
    ->countValues()
    ->arsort(); // Sort by frequency

// Generate error report
$report = "Error Report:\n";
foreach ($errorStats as $type => $count) {
    $report .= "- {$type}: {$count} occurrences\n";
}

// Find most recent critical error
$lastCritical = $errors
    ->filter(fn($e) => $e['type'] === 'Critical')
    ->last();
```

CoverArray bridges the gap between PHP's powerful array functions and modern object-oriented practices, making array manipulation more expressive, maintainable, and enjoyable.

Comparison Table: CoverArray Methods vs PHP Array Functions
-----------------------------------------------------------

[](#comparison-table-coverarray-methods-vs-php-array-functions)

\#PHP FunctionCoverArray MethodStatusNotes1`array_all``all()`✅Implemented with polyfill for older PHP versions2`array_any``any()`✅Implemented with polyfill for older PHP versions3`array_change_key_case``changeKeyCase()`✅Full implementation4`array_chunk``chunk()`✅Full implementation5`array_column``column()`✅Full implementation6`array_combine``combine()`✅Full implementation (static method)7`array_count_values``countValues()`✅Full implementation8`array_diff``diff()`✅Full implementation9`array_diff_assoc``diffAssoc()`✅Full implementation10`array_diff_key``diffKey()`✅Full implementation11`array_diff_uassoc``diffUassoc()`✅Full implementation12`array_diff_ukey``diffUkey()`✅Full implementation13`array_fill``fill()`✅Full implementation (static method)14`array_fill_keys``fillKeys()`✅Full implementation (static method)15`array_filter``filter()`✅Full implementation16`array_find``find()`✅Implemented with polyfill for older PHP versions17`array_find_key``findKey()`✅Implemented with polyfill for older PHP versions18`array_first``first()`✅Implemented with polyfill for older PHP versions19`array_flip``flip()`✅Full implementation20`array_intersect``intersect()`✅Full implementation21`array_intersect_assoc``intersectAssoc()`✅Full implementation22`array_intersect_key``intersectKey()`✅Full implementation23`array_intersect_uassoc``intersectUassoc()`✅Full implementation24`array_intersect_ukey``intersectUkey()`✅Full implementation25`array_is_list``isList()`✅Implemented with polyfill for older PHP versions26`array_key_exists``keyExists()`✅Full implementation27`array_key_first``keyFirst()`✅Uses built-in function28`array_key_last``keyLast()`✅Uses built-in function29`array_keys``keys()`✅Full implementation30`array_last``last()`✅Implemented with polyfill for older PHP versions31`array_map``map()`✅Full implementation32`array_merge``merge()`✅Full implementation33`array_merge_recursive``mergeRecursive()`✅Full implementation34`array_multisort``multisort()`✅Full implementation (mutating)35`array_pad``pad()`✅Full implementation36`array_pop``pop()`✅Full implementation (mutating)37`array_product``product()`✅Full implementation38`array_push``push()` / `append()`✅Full implementation (mutating)39`array_rand``rand()`✅Full implementation40`array_reduce``reduce()`✅Full implementation41`array_replace``replace()`✅Full implementation42`array_replace_recursive``replaceRecursive()`✅Full implementation43`array_reverse``reverse()`✅Full implementation44`array_search``search()`✅Full implementation45`array_shift``shift()`✅Full implementation (mutating)46`array_slice``slice()`✅Full implementation47`array_splice``splice()`✅Full implementation (mutating)48`array_sum``sum()`✅Full implementation49`array_udiff``udiff()`✅Full implementation50`array_udiff_assoc``udiffAssoc()`✅Full implementation51`array_udiff_uassoc``udiffUassoc()`✅Full implementation52`array_uintersect``uintersect()`✅Full implementation53`array_uintersect_assoc``uintersectAssoc()`✅Full implementation54`array_uintersect_uassoc``uintersectUassoc()`✅Full implementation55`array_unique``unique()`✅Full implementation56`array_unshift``unshift()` / `prepend()`✅Full implementation (mutating)57`array_values``values()`✅Full implementation58`array_walk``walk()`✅Full implementation (mutating)59`array_walk_recursive``walkRecursive()`✅Full implementation (mutating)60`arsort``arsort()`✅Full implementation (mutating)61`asort``asort()`✅Full implementation (mutating)62`compact``compact()`⚠️Not implementable (PHP scope limitations). Use: `CoverArray::fromArray(compact(...))`63`count``count()`✅Implementation of Countable interface64`current``current()`✅Full implementation65`end``end()`✅Full implementation (mutating)66`extract``extract()`✅Full implementation67`in_array``in()`✅Full implementation68`key``key()`✅Full implementation69`key_exists``keyExists()`✅Full implementation (same as array\_key\_exists)70`krsort``krsort()`✅Full implementation (mutating)71`ksort``ksort()`✅Full implementation (mutating)72`list``list()`⚠️Not implementable (language construct). Use: `list($a, $b) = $cover->getDataAsArray()`73`natcasesort``natcasesort()`✅Full implementation (mutating)74`natsort``natsort()`✅Full implementation (mutating)75`next``next()`✅Full implementation (mutating)76`pos``pos()`✅Alias of `current()`77`prev``prev()`✅Full implementation (mutating)78`range``range()`✅Full implementation (static method)79`reset``reset()`✅Full implementation (mutating)80`rsort``rsort()`✅Full implementation (mutating)81`shuffle``shuffle()`✅Full implementation (mutating)82`sort``sort()`✅Full implementation (mutating)83`uasort``uasort()`✅Full implementation (mutating)84`uksort``uksort()`✅Full implementation (mutating)85`usort``usort()`✅Full implementation (mutating)### Additional CoverArray Methods

[](#additional-coverarray-methods)

MethodPurposeAccess`__clone()`Creates a shallow copy with deep cloning of immediate object propertiesMagic`__get()`Gets a property value using object property syntaxMagic`__isset()`Checks if a property is setMagic`__serialize()`Serializes the object for serializationMagic`__set()`Sets a property value using object property syntaxMagic`__toString()`Returns a string representation of the objectMagic`__unserialize()`Unserializes the object from serialized dataMagic`__unset()`Unsets a propertyMagic`clear()`Clears all dataPublic`copy()`Creates and returns a copy of the current object instancePublic`each()`Applies a callback to each element and returns a new instance with preserved keys (immutable, non-recursive)Public`eachRecursive()`Recursively applies a callback to each element and returns a new instance (immutable, recursive)Public`fromArray()`Creates a CoverArray from a native PHP arrayPublic Static`fromExplode()`Creates a CoverArray from a string using explode()Public Static`fromJson()`Creates a CoverArray instance from a JSON stringPublic Static`get()`Returns data by keys of the current object using dot notationPublic`getData()`Returns the internal data array as-is without any conversionPublic`getDataAsArray()`Returns the current object's data as a native PHP arrayPublic`getIterator()`Returns an iterator for the array (IteratorAggregate interface)Public`implode()`Joins array elements with a stringPublic`isEmpty()`Checks if the array is emptyPublic`item()`Returns the collection element with the given index as the resultPublic`jsonSerialize()`Specifies data which should be serialized to JSON (JsonSerializable interface)Public`offsetExists()`Checks whether the specified offset exists in the array (ArrayAccess interface)Public`offsetGet()`Returns the value at the specified offset (ArrayAccess interface)Public`offsetSet()`Sets the value at the specified offset (ArrayAccess interface)Public`offsetUnset()`Unsets the value at the specified offset (ArrayAccess interface)Public`setData()`Sets the internal data for the CoverArrayPublic`toJson()`Converts the CoverArray to a JSON stringPublic

###  Health Score

35

—

LowBetter than 79% of packages

Maintenance81

Actively maintained with recent releases

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity40

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

Total

2

Last Release

99d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/d3676c6e77a3f7c58e87c58a43740f8155dd78f0bc1b6454253e6f32c5a89166?d=identicon)[Vasiliy-Makogon](/maintainers/Vasiliy-Makogon)

---

Top Contributors

[![Vasiliy-Makogon](https://avatars.githubusercontent.com/u/1030328?v=4)](https://github.com/Vasiliy-Makogon "Vasiliy-Makogon (137 commits)")

---

Tags

array-objectarray-wrapperarrayobjectcollectioncover-arrayphp-arrayphp-array-collectionphp-array-coverphp-array-objectphp-array-wrapperphp-collectionarrayArray objectarrayobjectphp-arrayphp collectionarray wrapperphp array objectcover arrayphp array coverphp array wrapperphp array collection

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/krugozor-cover/health.svg)

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

###  Alternatives

[doctrine/collections

PHP Doctrine Collections library that adds additional functionality on top of PHP arrays.

6.0k411.1M1.2k](/packages/doctrine-collections)[symfony/property-access

Provides functions to read and write from/to an object or array using a simple string notation

2.8k295.3M2.5k](/packages/symfony-property-access)[nette/utils

🛠 Nette Utils: lightweight utilities for string &amp; array manipulation, image handling, safe JSON encoding/decoding, validation, slug or strong password generating etc.

2.1k394.3M1.5k](/packages/nette-utils)[league/config

Define configuration arrays with strict schemas and access values with dot notation

564302.2M24](/packages/league-config)[cuyz/valinor

Dependency free PHP library that helps to map any input into a strongly-typed structure.

1.5k9.2M108](/packages/cuyz-valinor)[openlss/lib-array2xml

Array2XML conversion library credit to lalit.org

31052.5M47](/packages/openlss-lib-array2xml)

PHPackages © 2026

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