2017 © Pedro Peláez
 

library collection

Easy way to iterate over your data

image

fiv/collection

Easy way to iterate over your data

  • Monday, January 25, 2016
  • by funivan
  • Repository
  • 1 Watchers
  • 0 Stars
  • 11,818 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 3 Open issues
  • 2 Versions
  • 8 % Grown

The README.md

Collection

Latest Version Software License Build Status Coverage Status Quality Score Total Downloads, (*1)

Manipulate array of items in OOP style. ObjectCollection - contain/manipulate objects only with specific class TypedCollection - contain/manipulate items with defined validation rule BaseCollection - contain/manipulate any items, (*2)

ObjectCollection it the most useful collection. You can specify class of object and add only this objects. All validations perform ObjectCollection Other data types restricted. This class guarantee strict type data., (*3)

Install

Via Composer, (*4)

``` bash $ composer require fiv/collection, (*5)



## Base collection usage ``` php $collection = new \Fiv\Collection\BaseCollection(); $collection[] = 1; $collection[] = 2; echo $skeleton->getFirst()

Example : ObjectCollection

In java there ara features like ArrayList<UserModel> in php you can extend ObjectCollection to UserModelCollection and define class name., (*6)

class UserModel {
  public function getName(){

  }
}

class UsersCollection extend  ObjectCollection {
  public function objectsClassName(){
    return 'UserModel';
  }
}

# .... 
$users = new UserCollection();

foreach($users as $user){
  # at this point you can drop out all you validations
  # ObjectCollection guarantee that all items are UserModel
  $user->getName(); 
}


$users->append(123); // Fail. 123 is not instance of UserModel  

Testing

bash $ ./vendor/bin/phpunit, (*7)

Contributing

Please see CONTRIBUTING for details., (*8)

Credits

License

The MIT License (MIT). Please see License File for more information., (*9)

The Versions

25/01 2016

dev-master

9999999-dev https://github.com/funivan/object-collection

Easy way to iterate over your data

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

collection

07/11 2014

0.0.1

0.0.1.0 https://github.com/funivan/object-collection

Abstract class for typed object collection

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

collection