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