AnnotationRequiredArgumentsException   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 14
dl 0
loc 22
ccs 13
cts 13
cp 1
rs 10
c 1
b 0
f 0
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A createFor() 0 20 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Cycle\Annotated\Exception;
6
7
class AnnotationRequiredArgumentsException extends AnnotationException
8
{
9 24
    public static function createFor(\ReflectionProperty $property, string $annotationClass, \Throwable $e): static
10
    {
11 24
        $column = new \ReflectionClass($annotationClass);
12
13 24
        $requiredArguments = [];
14 24
        foreach ($column->getConstructor()->getParameters() as $parameter) {
15 24
            if (!$parameter->isOptional()) {
16 24
                $requiredArguments[] = $parameter->getName();
17
            }
18
        }
19
20 24
        return new static(
21 24
            sprintf(
22 24
                'Some of required arguments [`%s`] is missed on `%s.%s.`',
23 24
                implode('`, `', $requiredArguments),
24 24
                $property->getDeclaringClass()->getName(),
25 24
                $property->getName()
26
            ),
27 24
            $e->getCode(),
28
            $e
29
        );
30
    }
31
}
32