| Total Complexity | 8 |
| Total Lines | 66 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 11 | class TypeParanoia extends TypeCertainty |
||
| 12 | { |
||
| 13 | const INDEX_SECOND_ARG = 2; |
||
| 14 | |||
| 15 | const INT_ARG_OFFSET = 5; |
||
| 16 | |||
| 17 | /** |
||
| 18 | * @tempalte T as class-string |
||
| 19 | */ |
||
| 20 | 644 | public static function IsThingStrings(string $maybe, string $thing) : bool |
|
| 23 | } |
||
| 24 | |||
| 25 | /** |
||
| 26 | * @param string|object $object |
||
| 27 | * |
||
| 28 | * @psalm-param class-string|object $object |
||
| 29 | */ |
||
| 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 | ); |
||
| 54 | } |
||
| 55 | } |
||
| 56 | } |
||
| 57 | |||
| 58 | 14 | /** |
|
| 59 | 2 | * @param string|object $object |
|
| 60 | * |
||
| 61 | * @psalm-param class-string<DefinesOwnIdPropertiesInterface>|DefinesOwnIdPropertiesInterface $object |
||
| 62 | */ |
||
| 63 | 2 | public static function ThrowIfNotDaftObjectIdPropertiesType( |
|
| 77 | ); |
||
| 78 | } |
||
| 80 |