Completed
Push — master ( 77319b...ee05cf )
by Théo
7s
created

Reference   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

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

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getId() 0 4 1
A throwExceptionOnInvalidBehaviour() 0 4 1
A returnNullOnInvalidBehaviour() 0 4 1
A ignoreOnInvalidBehaviour() 0 4 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
use Fidry\LaravelYaml\DependencyInjection\Builder\BuilderInterface;
15
16
/**
17
 * This definition is a simple object encapsulating to refer to another service.
18
 *
19
 * @author Théo FIDRY <[email protected]>
20
 */
21
final class Reference
22
{
23
    /**
24
     * @var string
25
     */
26
    private $id;
27
28
    /**
29
     * @var int
30
     */
31
    private $invalidBehavior;
32
33
    /**
34
     * @param string $id              The service identifier
35
     * @param int    $invalidBehavior The behavior when the service cannot be found
36
     *
37
     * @see Container
38
     */
39 18
    public function __construct($id, $invalidBehavior)
40
    {
41 18
        $this->id = $id;
42 18
        $this->invalidBehavior = $invalidBehavior;
43 18
    }
44
45
    /**
46
     * @return string
47
     */
48 18
    public function getId()
49
    {
50 18
        return $this->id;
51
    }
52
53
    /**
54
     * @return bool
55
     */
56 18
    public function throwExceptionOnInvalidBehaviour()
57
    {
58 18
        return BuilderInterface::EXCEPTION_ON_INVALID_REFERENCE === $this->invalidBehavior;
59
    }
60
61
    /**
62
     * @return bool
63
     */
64 18
    public function returnNullOnInvalidBehaviour()
65
    {
66 18
        return BuilderInterface::NULL_ON_INVALID_REFERENCE === $this->invalidBehavior;
67
    }
68
69
    /**
70
     * @return bool
71
     */
72 18
    public function ignoreOnInvalidBehaviour()
73
    {
74 18
        return BuilderInterface::IGNORE_ON_INVALID_REFERENCE === $this->invalidBehavior;
75
    }
76
}
77