Last Updated | | Ratings | | Unique User Downloads | | Download Rankings |
2016-07-18 (3 months ago) | | Not enough user ratings | | Total: 110 This week: 2 | | All time: 8,416 This week: 591 |
|
Description | | Author |
This package can manage sets of arrays or objects as collections.
It provides two classes that can store unique values of arrays or objects.
It also provides a trait that provides basic functionality to any of the classes to manage the collection values. Innovation Award
August 2016
Number 7
Prize: One copy of the Zend Studio |
PHP is very good at dealing with arrays of values. It provides interfaces that can let developers create classes that can manipulate lists of values using the regular array syntax and functions.
Often the code for manipulating different types of values is the same for different classes that implement array interfaces.
This package provides a trait that can manipulate collections of unique values that can be either arrays and objects. The trait may be reused by other classes that implement similar collections of other types of values.
Manuel Lemos |
| |
|
|
Innovation award
Nominee: 4x |
|
Details
If-Then-Else Collection Library
Class set for collections
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.
Usage
<?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;
}
|
Applications that use this package |
|
No pages of applications that use this class were specified.
If you know an application of this package, send a message to the author to add a link here.