| Total Complexity | 6 |
| Total Lines | 48 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 13 | #[Attribute(Attribute::TARGET_CLASS | Attribute::TARGET_CLASS_CONSTANT | Attribute::IS_REPEATABLE)] |
||
| 14 | class Meta |
||
| 15 | { |
||
| 16 | /** |
||
| 17 | * The declared meta and related values. |
||
| 18 | * |
||
| 19 | * @var array<string, mixed> |
||
| 20 | */ |
||
| 21 | protected array $all; |
||
| 22 | |||
| 23 | /** |
||
| 24 | * Instantiate the class. |
||
| 25 | */ |
||
| 26 | 43 | public function __construct(mixed ...$meta) |
|
| 27 | { |
||
| 28 | 43 | foreach ($meta as $key => $value) { |
|
| 29 | 43 | if (! is_string($key)) { |
|
| 30 | 1 | throw new InvalidArgumentException('The name of meta must be a string'); |
|
| 31 | } |
||
| 32 | |||
| 33 | 42 | $this->all[$key] = $value; |
|
| 34 | } |
||
| 35 | } |
||
| 36 | |||
| 37 | /** |
||
| 38 | * Retrieve the meta names. |
||
| 39 | * |
||
| 40 | * @return string[] |
||
| 41 | */ |
||
| 42 | 2 | public function names(): array |
|
| 45 | } |
||
| 46 | |||
| 47 | /** |
||
| 48 | * Determine whether the given meta exists. |
||
| 49 | */ |
||
| 50 | 40 | public function has(string $meta): bool |
|
| 51 | { |
||
| 52 | 40 | return array_key_exists($meta, $this->all); |
|
| 53 | } |
||
| 54 | |||
| 55 | /** |
||
| 56 | * Retrieve the value for the given meta. |
||
| 57 | */ |
||
| 58 | 36 | public function get(string $meta): mixed |
|
| 61 | } |
||
| 62 | } |
||
| 63 |