PHP Classes
elePHPant
Icontem

File: tests/object_collection.php

Recommend this page to a friend!
  Classes of Kiril Savchev  >  ITE Collection  >  tests/object_collection.php  >  Download  
File: tests/object_collection.php
Role: Example script
Content type: text/plain
Description: object collection examples
Class: ITE Collection
Manage sets of arrays or objects as collections
Author: By
Last change:
Date: 3 years ago
Size: 516 bytes
 

 

Contents

Class file image Download
<?php

chdir
(realpath(__DIR__.'/../..'));

require_once
'./vendor/autoload.php';

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