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

Reference::__toString()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
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