| Conditions | 6 |
| Paths | 4 |
| Total Lines | 23 |
| Code Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 15 |
| CRAP Score | 6 |
| Changes | 0 | ||
| 1 | <?php |
||
| 22 | 20 | public static function ThrowIfNotType( |
|
| 23 | $object, |
||
| 24 | int $argument, |
||
| 25 | string $class, |
||
| 26 | string $function, |
||
| 27 | string ...$types |
||
| 28 | ) : void { |
||
| 29 | 20 | foreach ($types as $i => $type) { |
|
| 30 | 20 | if ( ! interface_exists($type) && ! class_exists($type)) { |
|
| 31 | 2 | throw new InvalidArgumentException( |
|
| 32 | 'Argument ' . |
||
| 33 | 2 | (self::INT_ARG_OFFSET + $i) . |
|
| 34 | 2 | ' passed to ' . |
|
| 35 | 2 | __METHOD__ . |
|
| 36 | 2 | ' must be a class or interface!' |
|
| 37 | ); |
||
| 38 | 18 | } elseif ( ! is_a($object, $type, is_string($object))) { |
|
| 39 | 12 | throw new DaftObjectRepositoryTypeByClassMethodAndTypeException( |
|
| 40 | 12 | $argument, |
|
| 41 | 12 | $class, |
|
| 42 | 12 | $function, |
|
| 43 | 12 | $type, |
|
| 44 | 18 | is_string($object) ? $object : get_class($object) |
|
| 45 | ); |
||
| 72 |