| Conditions | 6 |
| Paths | 4 |
| Total Lines | 23 |
| Code Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 7 |
| CRAP Score | 6 |
| Changes | 0 | ||
| 1 | <?php |
||
| 30 | public static function ThrowIfNotType( |
||
| 31 | $object, |
||
| 32 | int $argument, |
||
| 33 | 206 | string $class, |
|
| 34 | string $function, |
||
| 35 | 206 | string ...$types |
|
| 36 | 168 | ) : void { |
|
| 37 | foreach ($types as $i => $type) { |
||
| 38 | if ( ! interface_exists($type) && ! class_exists($type)) { |
||
| 39 | 38 | throw new InvalidArgumentException( |
|
| 40 | 'Argument ' . |
||
| 41 | (self::INT_ARG_OFFSET + $i) . |
||
| 42 | 2 | ' passed to ' . |
|
| 43 | __METHOD__ . |
||
| 44 | 2 | ' must be a class or interface!' |
|
| 45 | ); |
||
| 46 | } elseif ( ! is_a($object, $type, is_string($object))) { |
||
| 47 | throw new DaftObjectRepositoryTypeByClassMethodAndTypeException( |
||
| 48 | $argument, |
||
| 49 | $class, |
||
| 50 | $function, |
||
| 51 | $type, |
||
| 52 | 14 | is_string($object) ? $object : get_class($object) |
|
| 53 | ); |
||
| 80 |