aaronbullard / collections
There is no license information available for the latest version (dev-master) of this package.
Generic class to make a collection of any object type.
dev-master
2016-06-16 02:52 UTC
Requires
- php: >=5.4.0
Requires (Dev)
- fzaninotto/faker: ~1.4
- mockery/mockery: 0.9.*
- phpunit/phpunit: ~4.0
This package is auto-updated.
Last update: 2024-11-12 12:17:25 UTC
README
A base Collection class that when extended will ensure that all items added to the collection are of a single type. Type can be determined by a static property or inferred from the extended classes namespace.
Getting started
Clone repo.
Install dependencies
From within the cloned folder collections
run:
Composer dependencies
composer install
Testing
composer test
Usage
<?php
use Aaronbullard\Collections\Collection;
class Car {
public $model;
public function pressHorn(){
return "Honk!";
}
}
class CarCollection extends Collection {}
$cars = new CarCollection;
$numOfCars = 10;
$count = 0;
while($count < $numOfCars){
$cars[$count] = new Car();
$count++;
}
count($cars); //10
$cars[3]->pressHorn(); //"Honk!"