Skip to content
This repository has been archived by the owner on Jan 6, 2019. It is now read-only.

KasselerCMS/collection

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Collection Component

Build Status Scrutinizer Code Quality Latest Stable Version Total Downloads Latest Unstable Version License

Requirements

  • PHP >= 5.4

Installation

$ composer require kasseler/collection

Usage

$collection = new ArrayCollection([
    'one' => 1,
    'two' => 2,
    'three' => 3,
    'four' => 4,
    'five' => 5,
]);

echo $collection->get('one'); // return one key
echo $collection->two; // return two key
echo $collection['three']; // return three key

foreach ($collection as $key => $value) {
    /*
    * return
    * key[one]   = '1';
    * key[two]   = '2';
    * key[three] = '3';
    * key[four]  = '4';
    * key[five]  = '5';
    */
    echo sprintf("\nkey[%s] = '%s';", $key, $value);
}

echo $collection; //return serialize array

unset($collection['four']);
$collection->remove('five');

echo count($collection); // return 3