typomedia/collection

Basic Collection Class

1.0.4 2022-02-18 07:15 UTC

This package is auto-updated.

Last update: 2024-11-18 13:40:32 UTC


README

Ease of use collection class. 100% Code Coverage in Tests.

The Library is PSR-1, PSR-4, PSR-12 compliant.

Requirements

  • >= PHP 7.2

Dependencies

  • none

Install

composer require typomedia/collection

Usage

use Typomedia\Collection\Collection;

$data = [
    'Moretti' => [
        'name' => 'Style Ale',
        'style' => 'European Amber Lager',
        'alcohol' => '9.1%'
    ]
];

$collection = new Collection();
$key = md5(serialize($data));

$collection->set((object)$data, $key);
$collection->get($key);
$collection->first();
$collection->last();
$collection->keys();
$collection->find('name', 'Style Ale');
$collection->delete($key);