aaronbullard / collections
Generic class to make a collection of any object type.
Installs: 155
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/aaronbullard/collections
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: 2025-10-12 14:12:24 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!"