mc-cms-namelessmc/core/classes/Collections/CollectionManager.php
Sam 6f15e14392
chore: fix styleci (#3588)
Co-authored-by: Sam <samerton@users.noreply.github.com>
2025-03-29 10:50:03 +00:00

47 lines
1.2 KiB
PHP

<?php
/**
* Provides static access to manage and get Collections.
*
* @package NamelessMC\Collections
* @see Collection
* @author Samerton
* @version 2.0.0-pr8
* @license MIT
*/
class CollectionManager
{
/** @var Collection[] */
private static array $_collections = [];
public static function addItemToCollection(string $collection, CollectionItemBase $item): void
{
if (!isset(self::$_collections[$collection])) {
self::$_collections[$collection] = new Collection();
}
self::$_collections[$collection]->addItem($item);
}
/**
* @param string $collection
* @return CollectionItemBase[]
*/
public static function getFullCollection(string $collection): array
{
return isset(self::$_collections[$collection])
? self::$_collections[$collection]->getAllItems()
: [];
}
/**
* @param string $collection
* @return CollectionItemBase[]
*/
public static function getEnabledCollection(string $collection): array
{
return isset(self::$_collections[$collection])
? self::$_collections[$collection]->getEnabledItems()
: [];
}
}