PHP code example of hjerichen / collections
1. Go to this page and download the library: Download hjerichen/collections 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/ */
hjerichen / collections example snippets
use HJerichen\Collections\ObjectCollection;
class SomeClassCollection extends ObjectCollection
{
/**
* @param $elements SomeClass[]
*/
public function __construct(array $elements = [])
{
parent::__construct(SomeClass::class, $elements);
}
/**
* This Method is for static code analysis (Code Completion).
* @return Traversable | SomeClass[]
*/
public function getIterator(): Traversable
{
return parent::getIterator();
}
/**
* This Method is for static code analysis (Code Completion).
*/
public function offsetGet($offset): ?SomeClass
{
return parent::offsetGet($offset);
}
}