1. Go to this page and download the library: Download silvanus/collection library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
silvanus / collection example snippets
// Parent class.
use Silvanus\Collection\AbstractCollection;
class DummyCollection extends AbstractCollection
{
/**
* Provide your class with getType function.
* Return fully qualified namespace of your tpye.
*/
protected function getType() : string {
return 'Acme\App\DummyEntity';
}
}
// Your collection
use Acme\App\DummyCollection;
// Your object.
use Acme\App\DummyEntity;
$collection = new DummyCollection();
// All good.
$collection[] = new DummyEntity(1);
$collection[] = new DummyEntity(2);
// Exception thrown
$collection[] = new DateTime();
// Your collection
use Acme\App\DummyCollection;
// Your object.
use Acme\App\DummyEntity;
$array = array( new DummyEntity(1), new DummyEntity(2), new DummyEntity(3) );
// Will throw exceptions if incorrect types in array.
$collection = new DummyCollection( $array );
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.