PHP Classes


Recommend this page to a friend!
  Classes of Kiril Savchev   ITE Collection   Download  
Role: Documentation
Content type: text/markdown
Description: readme file
Class: ITE Collection
Manage sets of arrays or objects as collections
Author: By
Last change:
Date: 7 years ago
Size: 1,615 bytes


Class file image Download

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.


    // ArrayCollection usage:
    use Ite\Collection\ArrayCollection;

    $collection = new ArrayCollection();

    $collection2 = new ArrayCollection([1,44,'asd', 5 => PHP_INT_MAX]);
    //$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($c); -> throw exception
    foreach ($collection as $key => $val) {
            echo $key.': '.get_class($val).PHP_EOL;