| Conditions | 5 |
| Paths | 4 |
| Total Lines | 17 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 13 |
| CRAP Score | 5 |
| Changes | 2 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 21 | 48 | public function __construct($key) |
|
| 22 | { |
||
| 23 | 48 | if (is_array($key)) { |
|
| 24 | 3 | if (! isset($key['key'])) { |
|
| 25 | 1 | throw new InvalidArgumentException('Provided array doesn\'t include a "key" element'); |
|
| 26 | } |
||
| 27 | |||
| 28 | 2 | $this->key = $key['key']; |
|
| 29 | 47 | } elseif (is_string($key)) { |
|
| 30 | 44 | $this->key = $key; |
|
| 31 | 44 | } else { |
|
| 32 | 1 | throw new InvalidArgumentException(sprintf( |
|
| 33 | 1 | 'Expected "array" or "string", provided "%s"', |
|
| 34 | 1 | is_object($key) ? get_class($key) : gettype($key) |
|
| 35 | 1 | )); |
|
| 36 | } |
||
| 37 | 46 | } |
|
| 38 | |||
| 55 |