Completed
Push — master ( f46373...d10f54 )
by
unknown
04:56
created

PropertyDefinition::setPropertyName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
ccs 3
cts 3
cp 1
cc 1
eloc 3
nc 1
nop 1
crap 1
1
<?php declare(strict_types = 1);
2
/**
3
 * Created by PhpStorm.
4
 * User: root
5
 * Date: 02.08.16
6
 * Time: 0:46.
7
 */
8
namespace samsonframework\container\definition;
9
10
use samsonframework\container\definition\reference\ReferenceInterface;
11
use samsonframework\container\exception\ReferenceNotImplementsException;
12
use samsonframework\container\metadata\ClassMetadata;
13
use samsonframework\container\metadata\PropertyMetadata;
14
15
/**
16
 * Class PropertyDefinition
17
 *
18
 * @package samsonframework\container\definition
19
 */
20
class PropertyDefinition extends AbstractPropertyDefinition implements PropertyBuilderInterface
21
{
22
    /** @var string Property name */
23
    protected $propertyName;
24
25
    /**
26
     * Define argument
27
     *
28
     * @param ReferenceInterface $dependency
29
     * @return PropertyDefinition
30
     */
31 1
    public function defineDependency(ReferenceInterface $dependency): PropertyDefinition
32
    {
33 1
        $this->dependency = $dependency;
34
35 1
        return $this;
36
    }
37
38
    /**
39
     * Get property metadata
40
     *
41
     * @param ClassMetadata $classMetadata
42
     * @return PropertyMetadata
43
     * @throws ReferenceNotImplementsException
44
     */
45
    public function toPropertyMetadata(ClassMetadata $classMetadata): PropertyMetadata
46
    {
47
        $propertyMetadata = new PropertyMetadata($classMetadata);
48
        $propertyMetadata->name = $this->getPropertyName();
49
        $propertyMetadata->dependency = $this->resolveReference($this->getValue());
0 ignored issues
show
Bug introduced by
The method resolveReference() does not exist on samsonframework\containe...tion\PropertyDefinition. Did you maybe mean resolveReferenceValue()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
50
51
        return $propertyMetadata;
52
    }
53
54
    /**
55
     * @return string
56
     */
57
    public function getPropertyName(): string
58
    {
59
        return $this->propertyName;
60
    }
61
62
    /**
63
     * @param string $propertyName
64
     * @return AbstractPropertyDefinition
65
     */
66 2
    public function setPropertyName(string $propertyName): AbstractPropertyDefinition
67
    {
68 2
        $this->propertyName = $propertyName;
69
70 2
        return $this;
71
    }
72
}
73