| Total Complexity | 4 |
| Total Lines | 39 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 10 | trait AttributedTrait |
||
| 11 | { |
||
| 12 | /** @var array<non-empty-string, mixed> */ |
||
|
|
|||
| 13 | private array $attributes = []; |
||
| 14 | |||
| 15 | /** |
||
| 16 | * @return array<non-empty-string, mixed> Attributes derived from the context. |
||
| 17 | */ |
||
| 18 | 4 | public function getAttributes(): array |
|
| 19 | { |
||
| 20 | 4 | return $this->attributes; |
|
| 21 | } |
||
| 22 | |||
| 23 | /** |
||
| 24 | * @param non-empty-string $name |
||
| 25 | */ |
||
| 26 | 3 | public function getAttribute(string $name, mixed $default = null): mixed |
|
| 27 | { |
||
| 28 | 3 | return $this->attributes[$name] ?? $default; |
|
| 29 | } |
||
| 30 | |||
| 31 | /** |
||
| 32 | * @param non-empty-string $name |
||
| 33 | */ |
||
| 34 | 6 | public function withAttribute(string $name, mixed $value): static |
|
| 39 | } |
||
| 40 | |||
| 41 | /** |
||
| 42 | * @param non-empty-string $name |
||
| 43 | */ |
||
| 44 | 1 | public function withoutAttribute(string $name): static |
|
| 51 |