22declare(strict_types=1);
24namespace pocketmine\data\bedrock;
28use pocketmine\utils\SingletonTrait;
30use
function array_keys;
33use
function is_string;
34use
function json_decode;
35use
const JSON_THROW_ON_ERROR;
45 private static function make() :
self{
51 foreach($map as $tagName => $ids){
52 if(!is_string($tagName)){
61 throw new AssumptionFailedError(
"Invalid item tag $tagName, expected string as ID, got " . gettype($id));
65 $cleanMap[$tagName] = $cleanIds;
68 return new self($cleanMap);
75 private array $tagToIdsMap = [];
86 $this->tagToIdsMap[$tag][$id] =
true;
96 return array_keys($this->tagToIdsMap[$tag] ?? []);
99 public function tagContainsId(
string $tag,
string $id) : bool{
100 return isset($this->tagToIdsMap[$tag][$id]);
103 public function addIdToTag(
string $tag,
string $id) : void{
104 $this->tagToIdsMap[$tag][$id] = true;
__construct(array $tagToIds)
getIdsForTag(string $tag)
static fileGetContents(string $fileName, bool $useIncludePath=false, $context=null, int $offset=0, ?int $length=null)
static stringifyKeys(array $array)