PHP code example of gamee / php-collections

1. Go to this page and download the library: Download gamee/php-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/ */

    

gamee / php-collections example snippets


use Gamee\Collections\Collection\UniqueObjectCollection;

/**
 * @extends UniqueObjectCollection<UserData>
 */
final class UserDataCollection extends UniqueObjectCollection
{

	/**
	 * @param UserData $item
	 * @return string|int
	 */
	protected function getIdentifier(object $item)
	{
		return $item->getId();
	}
}


use Gamee\Collections\Iterator\ObjectIterator;

class UserCredentialsDataIterator extends ObjectIterator
{

	public function current(): UserCredentialsData
	{
		return parent::current();
	}
}

use Gamee\Collections\Collection\ImmutableObjectCollection;

final class UserDataCollection extends ImmutableObjectCollection
{

	protected function getItemType(): string
	{
		return UserData::class;
	}


	public function current(): UserData
	{
		return parent::current();
	}
}