| Total Complexity | 5 |
| Total Lines | 30 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 9 | trait ParametersTrait |
||
| 10 | { |
||
| 11 | /** @var array<string, mixed> */ |
||
| 12 | private array $parameters = []; |
||
| 13 | |||
| 14 | public function has(string $key): bool |
||
| 15 | { |
||
| 16 | return isset($this->parameters[$key]); |
||
| 17 | } |
||
| 18 | |||
| 19 | public function get(string $key, mixed $default = null): mixed |
||
| 20 | { |
||
| 21 | return $this->parameters[$key] ?? $default; |
||
| 22 | } |
||
| 23 | |||
| 24 | public function ensure(string $key): mixed |
||
| 25 | { |
||
| 26 | return $this->get($key) ?? throw new RuntimeException("Missing key \"$key\""); |
||
| 27 | } |
||
| 28 | |||
| 29 | /** @return array<string, mixed> */ |
||
| 30 | public function all(): array |
||
| 31 | { |
||
| 32 | return $this->parameters; |
||
| 33 | } |
||
| 34 | |||
| 35 | /** @return array<string, mixed> */ |
||
| 36 | public function jsonSerialize(): array |
||
| 39 | } |
||
| 40 | } |
||
| 41 |