Completed
Push — master ( 821e5b...8cc443 )
by Vitaly
24s
created

Instance::toPropertyMetadata()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 1
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php declare(strict_types = 1);
2
/**
3
 * Created by PhpStorm.
4
 * User: root
5
 * Date: 27.07.2016
6
 * Time: 1:55.
7
 */
8
namespace samsonframework\container\collection;
9
10
use samsonframework\container\configurator\ClassConfiguratorInterface;
11
use samsonframework\container\configurator\PropertyConfiguratorInterface;
12
use samsonframework\container\metadata\ClassMetadata;
13
use samsonframework\container\metadata\PropertyMetadata;
14
15
/**
16
 * Class collection configurator class.
17
 * @see    \samsonframework\container\configurator\ScopeConfigurator
18
 *
19
 * @author Vitaly Egorov <[email protected]>
20
 *
21
 * *Resolve class attribute, "Class" - name more better but it reserved in php
22
 */
23
class Instance implements ClassConfiguratorInterface, PropertyConfiguratorInterface, CollectionAttributeConfiguratorInterface
24
{
25
    /**
26
     * @var string Configurator key
27
     */
28
    const CONFIGURATOR_KEY = 'class';
29
30
    /**
31
     * @var string Dependency class name
32
     */
33
    protected $className;
34
35
    /**
36
     * Class collection configurator constructor.
37
     *
38
     * @param string $className Class name
39
     */
40 1
    public function __construct(string $className)
41
    {
42 1
        $this->className = $className;
43 1
    }
44
45
    /* {@inheritDoc} */
46 1
    public function toClassMetadata(ClassMetadata $classMetadata)
47
    {
48 1
        $classMetadata->className = $this->className;
49 1
    }
50
51
    /* {@inheritDoc} */
52 1
    public function toPropertyMetadata(PropertyMetadata $propertyMetadata)
53
    {
54 1
        $propertyMetadata->dependency = $this->className;
55 1
    }
56
}
57