Completed
Pull Request — master (#52)
by Tom
04:13
created

ServiceDefinition::__construct()   B

Complexity

Conditions 5
Paths 16

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 8.8571
c 0
b 0
f 0
cc 5
eloc 6
nc 16
nop 3
1
<?php
2
3
namespace TomPHP\ContainerConfigurator;
4
5
final class ServiceDefinition
6
{
7
    /**
8
     * @var string
9
     */
10
    private $name;
11
12
    /**
13
     * @var string
14
     */
15
    private $class;
16
17
    /**
18
     * @var bool
19
     */
20
    private $singleton;
21
22
    /**
23
     * @var array
24
     */
25
    private $arguments;
26
27
    /**
28
     * @var array
29
     */
30
    private $methods;
31
32
    /**
33
     * @param string $name
34
     * @param array  $config
35
     * @param bool   $singletonDefault
36
     */
37
    public function __construct($name, array $config, $singletonDefault = false)
38
    {
39
        $this->name      = $name;
40
        $this->class     = isset($config['class']) ? $config['class'] : $name;
41
        $this->singleton = isset($config['singleton']) ? $config['singleton'] : $singletonDefault;
42
        $this->arguments = isset($config['arguments']) ? $config['arguments'] : [];
43
        $this->methods   = isset($config['methods']) ? $config['methods'] : [];
44
    }
45
46
    /**
47
     * @return string
48
     */
49
    public function getName()
50
    {
51
        return $this->name;
52
    }
53
54
    /**
55
     * @return string
56
     */
57
    public function getClass()
58
    {
59
        return $this->class;
60
    }
61
62
    /**
63
     * @return bool
64
     */
65
    public function isSingleton()
66
    {
67
        return $this->singleton;
68
    }
69
70
    /**
71
     * @return array
72
     */
73
    public function getArguments()
74
    {
75
        return $this->arguments;
76
    }
77
78
    /**
79
     * @return array
80
     */
81
    public function getMethods()
82
    {
83
        return $this->methods;
84
    }
85
}
86