Completed
Push — master ( 8cc443...0d7c83 )
by Vitaly
02:51
created

Instance   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 4
lcom 1
cbo 3
dl 0
loc 40
ccs 12
cts 12
cp 1
rs 10
c 2
b 0
f 1

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A toClassMetadata() 0 4 1
A toPropertyMetadata() 0 4 1
A toParameterMetadata() 0 4 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\ParameterConfiguratorInterface;
12
use samsonframework\container\configurator\PropertyConfiguratorInterface;
13
use samsonframework\container\metadata\ClassMetadata;
14
use samsonframework\container\metadata\ParameterMetadata;
15
use samsonframework\container\metadata\PropertyMetadata;
16
17
/**
18
 * Class collection configurator class.
19
 *
20
 * @see    \samsonframework\container\configurator\ScopeConfigurator
21
 *
22
 * @author Vitaly Egorov <[email protected]>
23
 *
24
 * *Resolve class attribute, "Class" - name more better but it reserved in php
25
 */
26
class Instance implements ClassConfiguratorInterface, PropertyConfiguratorInterface, ParameterConfiguratorInterface, CollectionAttributeConfiguratorInterface
27
{
28
    /**
29
     * @var string Configurator key
30
     */
31
    const CONFIGURATOR_KEY = 'class';
32
33
    /**
34
     * @var string Dependency class name
35
     */
36
    protected $className;
37
38
    /**
39
     * Class collection configurator constructor.
40
     *
41
     * @param string $className Class name
42
     */
43 1
    public function __construct(string $className)
44
    {
45 1
        $this->className = $className;
46 1
    }
47
48
    /* {@inheritDoc} */
49 1
    public function toClassMetadata(ClassMetadata $classMetadata)
50
    {
51 1
        $classMetadata->className = $this->className;
52 1
    }
53
54
    /* {@inheritDoc} */
55 1
    public function toPropertyMetadata(PropertyMetadata $propertyMetadata)
56
    {
57 1
        $propertyMetadata->dependency = $this->className;
58 1
    }
59
60
    /* {@inheritDoc} */
61 1
    public function toParameterMetadata(ParameterMetadata $parameterMetadata)
62
    {
63 1
        $parameterMetadata->dependency = $this->className;
64 1
    }
65
}
66