Passed
Push — 3.x ( 885785...4e5cb3 )
by Aleksei
01:36
created

AnnotationRequiredArgumentsException   A

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 12
    public static function createFor(\ReflectionProperty $property, string $annotationClass, \Throwable $e): static
10
    {
11 12
        $column = new \ReflectionClass($annotationClass);
12
13 12
        $requiredArguments = [];
14 12
        foreach ($column->getConstructor()->getParameters() as $parameter) {
15 12
            if (! $parameter->isOptional()) {
16 12
                $requiredArguments[] = $parameter->getName();
17
            }
18
        }
19
20 12
        return new static(
21 12
            sprintf(
22 12
                'Some of required arguments [`%s`] is missed on `%s.%s.`',
23 12
                implode('`, `', $requiredArguments),
24 12
                $property->getDeclaringClass()->getName(),
25 12
                $property->getName()
26
            ),
27 12
            $e->getCode(),
28
            $e
29
        );
30
    }
31
}
32