8773b8389110f5a0600ebdb921d8a53ff8297db9
[yaffs-website] / vendor / symfony / dependency-injection / Alias.php
1 <?php
2
3 /*
4  * This file is part of the Symfony package.
5  *
6  * (c) Fabien Potencier <fabien@symfony.com>
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 Symfony\Component\DependencyInjection;
13
14 class Alias
15 {
16     private $id;
17     private $public;
18     private $private;
19
20     /**
21      * @param string $id     Alias identifier
22      * @param bool   $public If this alias is public
23      */
24     public function __construct($id, $public = true)
25     {
26         $this->id = (string) $id;
27         $this->public = $public;
28         $this->private = 2 > func_num_args();
29     }
30
31     /**
32      * Checks if this DI Alias should be public or not.
33      *
34      * @return bool
35      */
36     public function isPublic()
37     {
38         return $this->public;
39     }
40
41     /**
42      * Sets if this Alias is public.
43      *
44      * @param bool $boolean If this Alias should be public
45      *
46      * @return $this
47      */
48     public function setPublic($boolean)
49     {
50         $this->public = (bool) $boolean;
51         $this->private = false;
52
53         return $this;
54     }
55
56     /**
57      * Sets if this Alias is private.
58      *
59      * When set, the "private" state has a higher precedence than "public".
60      * In version 3.4, a "private" alias always remains publicly accessible,
61      * but triggers a deprecation notice when accessed from the container,
62      * so that the alias can be made really private in 4.0.
63      *
64      * @param bool $boolean
65      *
66      * @return $this
67      */
68     public function setPrivate($boolean)
69     {
70         $this->private = (bool) $boolean;
71
72         return $this;
73     }
74
75     /**
76      * Whether this alias is private.
77      *
78      * @return bool
79      */
80     public function isPrivate()
81     {
82         return $this->private;
83     }
84
85     /**
86      * Returns the Id of this alias.
87      *
88      * @return string The alias id
89      */
90     public function __toString()
91     {
92         return $this->id;
93     }
94 }