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

AnnotationResolver   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 27.27%

Importance

Changes 18
Bugs 1 Features 7
Metric Value
wmc 3
c 18
b 1
f 7
lcom 1
cbo 2
dl 0
loc 46
rs 10
ccs 3
cts 11
cp 0.2727

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A resolve() 0 17 2
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