Recommend this page to a friend! |
![]() |
Info | Documentation | ![]() |
![]() |
![]() |
Reputation | Support forum | Blog | Links |
Ratings | Unique User Downloads | Download Rankings | ||||
![]() ![]() ![]() ![]() | Total: 130 | All time: 9,364 This week: 455![]() |
Version | License | PHP version | Categories | |||
ite-collection 1.1.2 | BSD License | 5.6 | PHP 5, Data types, Traits |
Description | Author | |||
This package can manage sets of arrays or objects as collections. Innovation Award
|
It contains two different types of collections - ArrayCollection and ObjectCollection. ArrayCollection stores unique values in array. ObjectCollection stores unique objects, instances of a given class.
<?php
// ArrayCollection usage:
use Ite\Collection\ArrayCollection;
$collection = new ArrayCollection();
$collection->set(12);
$collection->set("A");
//var_dump($collection->toArray());
$collection->set("B");
//var_dump($collection->toArray());
$collection2 = new ArrayCollection([1,44,'asd', 5 => PHP_INT_MAX]);
$collection->merge($collection2);
var_dump($collection->toArray());
//$max = $collection->remove(PHP_INT_MAX);
//var_dump($collection->toArray(), $max);
foreach ($collection as $key => $val) {
echo $key.': '.$val.PHP_EOL;
}
// ObjectCollection usage:
use Ite\Collection\ObjectCollection;
$collection = new ObjectCollection('\stdClass');
$a = new stdClass();
$b = new stdClass();
$c = new stdClass();
$d = new stdClass();
$e = new stdClass();
$collection->set($a);
$collection->set($b);
$collection->set($c);
//$collection->set($c); -> throw exception
$collection->set($d);
$collection->set($e);
foreach ($collection as $key => $val) {
echo $key.': '.get_class($val).PHP_EOL;
}
![]() |
File | Role | Description | ||
---|---|---|---|---|
![]() |
||||
![]() |
||||
![]() ![]() |
Conf. | composer file | ||
![]() ![]() |
Lic. | license | ||
![]() ![]() |
Doc. | readme file |
![]() |
/ | src |
File | Role | Description |
---|---|---|
![]() |
Class | ArrayCollection class |
![]() |
Class | CollectionInterface |
![]() |
Class | Base collection methods |
![]() |
Class | ObjectCollection class |
![]() |
/ | tests |
File | Role | Description |
---|---|---|
![]() ![]() |
Example | array collection tests |
![]() ![]() |
Example | object collection examples |
The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page. |
![]() |
Version Control | Unique User Downloads | Download Rankings | |||||||||||||||
0% |
|
|
User Ratings | ||||||||||||||||||||||||||||||
|
Applications that use this package |
If you know an application of this package, send a message to the author to add a link here.