Completed
Push — master ( 6ba652...6f597b )
by Vitaly
02:20
created

AnnotationResolver::resolve()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 17
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 12
Bugs 0 Features 6
Metric Value
c 12
b 0
f 6
dl 0
loc 17
rs 9.4285
ccs 0
cts 7
cp 0
cc 2
eloc 10
nc 2
nop 2
crap 6
1
<?php
2
/**
3
 * Created by Vitaly Iegorov <[email protected]>.
4
 * on 07.08.16 at 13:32
5
 */
6
namespace samsonframework\container\resolver;
7
8
use samsonframework\container\metadata\ClassMetadata;
9
10
/**
11
 * Annotation resolver implementation.
12
 *
13
 * @package samsonframework\container\resolver
14
 */
15
class AnnotationResolver implements Resolver
16
{
17
    /** @var Resolver */
18
    protected $classResolver;
19
20
    /** @var Resolver */
21
    protected $propertyResolver;
22
23
    /** @var Resolver */
24
    protected $methodResolver;
25
26
    /**
27
     * AnnotationResolver constructor.
28
     *
29
     * @param Resolver $classResolver
30
     * @param Resolver $propertyResolver
31
     * @param Resolver $methodResolver
32
     */
33
    public function __construct(Resolver $classResolver, Resolver $propertyResolver, Resolver $methodResolver)
34
    {
35
        $this->classResolver = $classResolver;
36
        $this->propertyResolver = $propertyResolver;
37
        $this->methodResolver = $methodResolver;
38 1
    }
39
40 1
    /**
41 1
     * {@inheritDoc}
42
     */
43
    public function resolve($classData, $identifier = null)
44
    {
45
        /** @var \ReflectionClass $classData */
46
47
        // Create and fill class metadata base fields
48
        $classMetadata = new ClassMetadata();
49
        $classMetadata->className = $classData->getName();
50
        $classMetadata->nameSpace = $classData->getNamespaceName();
51
        $classMetadata->identifier = $identifier ?: uniqid(__CLASS__, true);
52
        $classMetadata->name = $classMetadata->identifier;
53
54
        $this->classResolver->resolve($classData, $classMetadata);
0 ignored issues
show
Documentation introduced by
$classMetadata is of type object<samsonframework\c...metadata\ClassMetadata>, but the function expects a string|null.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
55
        $this->propertyResolver->resolve($classData, $classMetadata);
0 ignored issues
show
Documentation introduced by
$classMetadata is of type object<samsonframework\c...metadata\ClassMetadata>, but the function expects a string|null.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
56
        $this->methodResolver->resolve($classData, $classMetadata);
0 ignored issues
show
Documentation introduced by
$classMetadata is of type object<samsonframework\c...metadata\ClassMetadata>, but the function expects a string|null.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
57
58
        return $classMetadata;
59
    }
60
}
61