ServiceConfigurator   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 2
dl 0
loc 27
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A toClassMetadata() 0 7 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\configurator;
9
10
use samsonframework\container\Builder;
11
use samsonframework\container\metadata\ClassMetadata;
12
13
/**
14
 * Service class configurator.
15
 *
16
 * This configurator adds class to container service scope.
17
 * @see    samsonframework\container\Container::SCOPE_SERVICE
18
 *
19
 * @author Vitaly Egorov <[email protected]>
20
 */
21
class ServiceConfigurator extends ScopeConfigurator
22
{
23
    /** @var string Class service name */
24
    protected $serviceName;
25
26
    /**
27
     * ServiceConfigurator constructor.
28
     *
29
     * @param string $serviceData Class service name
30
     */
31
    public function __construct(string $serviceData)
32
    {
33
        $this->serviceName = $serviceData;
34
35
        // Add to service scopes
36
        parent::__construct(Builder::SCOPE_SERVICES);
37
    }
38
39
    /** {@inheritdoc} */
40
    public function toClassMetadata(ClassMetadata $classMetadata)
41
    {
42
        parent::toClassMetadata($classMetadata);
43
44
        // Add service name
45
        $classMetadata->name = $this->serviceName;
46
    }
47
}
48