Completed
Push — master ( daa27a...019907 )
by Vitaly
03:25
created

ServiceConfigurator   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
lcom 1
cbo 2
dl 0
loc 27
ccs 8
cts 8
cp 1
rs 10
c 1
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A toClassMetadata() 0 7 1
1
<?php
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\ContainerBuilder;
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 $serviceName Class service name
30
     */
31 9
    public function __construct(string $serviceName)
32
    {
33 9
        $this->serviceName = $serviceName;
34
35
        // Add to service scopes
36 9
        parent::__construct(ContainerBuilder::SCOPE_SERVICES);
37 9
    }
38
39
    /** {@inheritdoc} */
40 9
    public function toClassMetadata(ClassMetadata $classMetadata)
41
    {
42 9
        parent::toClassMetadata($classMetadata);
43
44
        // Add service name
45 9
        $classMetadata->name = $this->serviceName;
46 9
    }
47
}
48