PHP Classes

ITE Collection: Manage sets of arrays or objects as collections

Recommend this page to a friend!
  Info   View files Documentation   View files View files (9)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
StarStarStarStar 72%Total: 130 This week: 1All time: 9,337 This week: 571Up
Version License PHP version Categories
ite-collection 1.1.2BSD License5.6PHP 5, Data types, Traits
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
PHP Programming Innovation award nominee
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
Picture of Kiril Savchev
  Performance   Level  
Name: Kiril Savchev <contact>
Classes: 6 packages by
Country: Bulgaria Bulgaria
Age: 38
All time rank: 266718 in Bulgaria Bulgaria
Week rank: 103 Up1 in Bulgaria Bulgaria Up
Innovation award
Innovation award
Nominee: 5x

Documentation

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

  Files folder image Files  
File Role Description
Files folder imagesrc (4 files)
Files folder imagetests (2 files)
Accessible without login Plain text file composer.json Conf. composer file
Accessible without login Plain text file license Lic. license
Accessible without login Plain text file README.md Doc. readme file

  Files folder image Files  /  src  
File Role Description
  Plain text file ArrayCollection.php Class ArrayCollection class
  Plain text file CollectionInterface.php Class CollectionInterface
  Plain text file CollectionTrait.php Class Base collection methods
  Plain text file ObjectCollection.php Class ObjectCollection class

  Files folder image Files  /  tests  
File Role Description
  Accessible without login Plain text file array_collection.php Example array collection tests
  Accessible without login Plain text file object_collection.php Example object collection examples

 Version Control Unique User Downloads Download Rankings  
 0%
Total:130
This week:1
All time:9,337
This week:571Up
 User Ratings  
 
 All time
Utility:91%StarStarStarStarStar
Consistency:91%StarStarStarStarStar
Documentation:83%StarStarStarStarStar
Examples:91%StarStarStarStarStar
Tests:-
Videos:-
Overall:72%StarStarStarStar
Rank:188