Completed
Push — master ( e9d1ee...cb5c09 )
by Théo
06:38
created

Service   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 100
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 68%

Importance

Changes 4
Bugs 0 Features 4
Metric Value
wmc 7
c 4
b 0
f 4
lcom 0
cbo 2
dl 0
loc 100
ccs 17
cts 25
cp 0.68
rs 10

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 1
A getName() 0 4 1
A getClass() 0 4 1
A getArguments() 0 4 1
A getAutowiringTypes() 0 4 1
A getTags() 0 4 1
A createFromDecoration() 0 10 1
1
<?php
2
3
/*
4
 * This file is part of the LaravelYaml package.
5
 *
6
 * (c) Théo FIDRY <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Fidry\LaravelYaml\DependencyInjection\Definition;
13
14
/**
15
 * @author Théo FIDRY <[email protected]>
16
 */
17
final class Service implements ServiceInterface
18
{
19
    /**
20
     * @var string
21
     */
22
    private $name;
23
24
    /**
25
     * @var string
26
     */
27
    private $class;
28
29
    /**
30
     * @var string[]|Reference[]
31
     */
32
    private $arguments;
33
34
    /**
35
     * @var string[]
36
     */
37
    private $autowiringTypes;
38
39
    /**
40
     * @var array
41
     */
42
    private $tags;
43
44
    /**
45
     * @param string               $name            Name of the service
46
     * @param string               $class           FQCN of the service
47
     * @param string[]|Reference[] $arguments       List of arguments passed for the service instantiation
48
     * @param array|null           $autowiringTypes List of autowired classes
49
     * @param array|null           $tags
50
     */
51 6
    public function __construct($name, $class, array $arguments = [], array $autowiringTypes = [], array $tags = [])
52
    {
53 6
        $this->name = $name;
54 6
        $this->class = $class;
55 6
        $this->arguments = $arguments;
56 6
        $this->autowiringTypes = $autowiringTypes;
57 6
        $this->tags = $tags;
58 6
    }
59
60
    /**
61
     * {@inheritdoc}
62
     */
63 6
    public function getName()
64
    {
65 6
        return $this->name;
66
    }
67
68
    /**
69
     * {@inheritdoc}
70
     */
71 6
    public function getClass()
72
    {
73 6
        return $this->class;
74
    }
75
76
    /**
77
     * {@inheritdoc}
78
     */
79 6
    public function getArguments()
80
    {
81 6
        return $this->arguments;
82
    }
83
84
    /**
85
     * {@inheritdoc}
86
     */
87 6
    public function getAutowiringTypes()
88
    {
89 6
        return $this->autowiringTypes;
90
    }
91
92
    /**
93
     * {@inheritdoc}
94
     */
95 6
    public function getTags()
96
    {
97 6
        return $this->tags;
98
    }
99
100
    /**
101
     * @param ServiceInterface    $service
102
     * @param DecorationInterface $decoration
103
     *
104
     * @return $this
105
     */
106
    public static function createFromDecoration(ServiceInterface $service, DecorationInterface $decoration)
107
    {
108
        return new self(
109
            $decoration->getDecoration()[1],
110
            $service->getClass(),
111
            $service->getArguments(),
112
            $service->getAutowiringTypes(),
113
            $service->getTags()
114
        );
115
    }
116
}
117