| Conditions | 7 |
| Paths | 16 |
| Total Lines | 44 |
| Code Lines | 24 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 22 | public function __construct( |
||
| 23 | $annotation, |
||
| 24 | string $argumentName, |
||
| 25 | $class = null |
||
| 26 | ) { |
||
| 27 | if ($annotation instanceof AnnotationInterface) { |
||
| 28 | $annotation = get_class($annotation); |
||
| 29 | } |
||
| 30 | |||
| 31 | if ($class instanceof ReflectionClass) { |
||
| 32 | $class = $class->getName(); |
||
| 33 | } |
||
| 34 | |||
| 35 | if (!is_string($annotation)) { |
||
|
|
|||
| 36 | throw new InvalidArgumentException( |
||
| 37 | sprintf( |
||
| 38 | 'Invalid annotation (string|%s) attribute.', |
||
| 39 | AnnotationInterface::class, |
||
| 40 | ) |
||
| 41 | ); |
||
| 42 | } |
||
| 43 | |||
| 44 | if ($class !== null && !is_string($class)) { |
||
| 45 | throw new InvalidArgumentException( |
||
| 46 | 'Invalid class (string|ReflectionClass|null) attribute.', |
||
| 47 | ); |
||
| 48 | } |
||
| 49 | |||
| 50 | if ($class) { |
||
| 51 | $message = sprintf( |
||
| 52 | 'Argument "%s" is mandatory for annotation %s on %s.', |
||
| 53 | $argumentName, |
||
| 54 | $annotation, |
||
| 55 | $class |
||
| 56 | ); |
||
| 57 | } else { |
||
| 58 | $message = sprintf( |
||
| 59 | 'Argument "%s" is mandatory for annotation %s.', |
||
| 60 | $argumentName, |
||
| 61 | $annotation, |
||
| 62 | ); |
||
| 63 | } |
||
| 64 | |||
| 65 | parent::__construct($message); |
||
| 66 | } |
||
| 68 | } |