PHP code example of piotrpress / typed-collection
1. Go to this page and download the library: Download piotrpress/typed-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/ */
piotrpress / typed-collection example snippets
use PiotrPress\TypedCollection;
$collection = new TypedCollection( type: Example::class, values: [ new Example() ] );
$collection[0]; // returns Example instance from key 0 of the collection
$collection[] = new Example(); // adds new Example instance to the collection
foreach( $collection as $value ) // iterates over the collection
use PiotrPress\TypedCollection;
use PiotrPress\TypedCollection\Type;
new TypedCollection( Type|string $type, array $values = [] );