Something went wrong. Try again.
Parse and validate AT Protocol Lexicons with DTO generation for Laravel
Something went wrong. Try again.
1.2 kB · 58 lines
PHP
at dev
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859<?php
namespace SocialDept\AtpSchema\Parser;
use SocialDept\AtpSchema\Contracts\LexiconRegistry;use SocialDept\AtpSchema\Data\LexiconDocument;
class InMemoryLexiconRegistry implements LexiconRegistry{ /** * Registered lexicon documents. * * @var array<string, LexiconDocument> */ protected array $documents = [];
/** * Register a lexicon document. */ public function register(LexiconDocument $document): void { $this->documents[$document->getNsid()] = $document; }
/** * Get a lexicon document by NSID. */ public function get(string $nsid): ?LexiconDocument { return $this->documents[$nsid] ?? null; }
/** * Check if a lexicon document exists. */ public function has(string $nsid): bool { return isset($this->documents[$nsid]); }
/** * Get all registered lexicon documents. * * @return array<string, LexiconDocument> */ public function all(): array { return $this->documents; }
/** * Clear all registered lexicon documents. */ public function clear(): void { $this->documents = []; }}