| Conditions | 3 |
| Paths | 3 |
| Total Lines | 22 |
| Code Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 18 | public function fromArray($params, string $key) |
||
| 19 | { |
||
| 20 | if (false === is_array($params)) { |
||
| 21 | throw new InvalidArgumentException( |
||
| 22 | sprintf('Value "%s" is not an array.', $params), |
||
| 23 | 0, |
||
| 24 | null, |
||
| 25 | $params |
||
| 26 | ); |
||
| 27 | } |
||
| 28 | |||
| 29 | if (false === array_key_exists($key, $params)) { |
||
| 30 | throw new InvalidArgumentException( |
||
| 31 | sprintf('Array does not contain an element with key "%s"', $key), |
||
| 32 | 0, |
||
| 33 | null, |
||
| 34 | $params |
||
| 35 | ); |
||
| 36 | } |
||
| 37 | |||
| 38 | return $params[$key]; |
||
| 39 | } |
||
| 40 | } |
||
| 41 |