gamee / php-collections
package of useful collections for php
Installs: 26 939
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 6
Forks: 1
Open Issues: 0
Requires
- php: >=8.0
Requires (Dev)
- codeception/codeception: ^4.1
- codeception/module-asserts: ^1.3
- gamee/php-code-checker-rules: ^3.0
- webmozart/assert: ^1.11
README
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(); } }