Completed
Push — master ( 03d9da...2dac9a )
by Tom
13s
created

ServiceDefinition::getClass()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

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