typomedia/collection

基本集合类

1.0.4 2022-02-18 07:15 UTC

This package is auto-updated.

Last update: 2024-09-18 13:22:19 UTC


README

易于使用的集合类。测试覆盖率100%。

该库符合PSR-1PSR-4PSR-12规范。

需求

  • >= PHP 7.2

依赖

安装

composer require typomedia/collection

用法

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);