Skip to content

gameeapp/php-collections

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

66 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Latest Stable Version License Total Downloads Build Status

php-collections

Useful PHP utilities (Collections, Iterators, etc)

UniqueObjectCollection usage

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();
	}
}

ObjectIterator usage

use Gamee\Collections\Iterator\ObjectIterator;

class UserCredentialsDataIterator extends ObjectIterator
{

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

ImmutableObjectCollection

use Gamee\Collections\Collection\ImmutableObjectCollection;

final class UserDataCollection extends ImmutableObjectCollection
{

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


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