| @@ 25-36 (lines=12) @@ | ||
| 22 | /** |
|
| 23 | * {@inheritdoc} |
|
| 24 | */ |
|
| 25 | public function get($descriptorKey): DescriptorInterface |
|
| 26 | { |
|
| 27 | if (!isset($this->descriptors[$descriptorKey])) { |
|
| 28 | throw new \InvalidArgumentException(sprintf( |
|
| 29 | 'Descriptor "%s" is not supported', |
|
| 30 | $descriptorKey, |
|
| 31 | implode('", "', array_keys($this->descriptors)) |
|
| 32 | )); |
|
| 33 | } |
|
| 34 | ||
| 35 | return $this->descriptors[$descriptorKey]; |
|
| 36 | } |
|
| 37 | ||
| 38 | /** |
|
| 39 | * {@inheritdoc} |
|
| @@ 29-38 (lines=10) @@ | ||
| 26 | * |
|
| 27 | * This is called when the user attempts to access a descriptor. |
|
| 28 | */ |
|
| 29 | public function validateKey(string $key) |
|
| 30 | { |
|
| 31 | if (false === isset($this->definitions[$key])) { |
|
| 32 | throw new \InvalidArgumentException(sprintf( |
|
| 33 | 'Descriptor "%s" not a permitted descriptor key. Did you make a typo? Permitted descriptors: "%s"', |
|
| 34 | $key, |
|
| 35 | implode('", "', array_keys($this->definitions)) |
|
| 36 | )); |
|
| 37 | } |
|
| 38 | } |
|
| 39 | ||
| 40 | /** |
|
| 41 | * Validate the descriptor key AND ensures that the given |
|