2011-01-07 14:44:29 +00:00
< ? php
2011-01-15 13:29:43 +00:00
/*
* This file is part of the Symfony package .
*
2011-03-06 11:40:06 +00:00
* ( c ) Fabien Potencier < fabien @ symfony . com >
2011-01-15 13:29:43 +00:00
*
* For the full copyright and license information , please view the LICENSE
* file that was distributed with this source code .
*/
2011-01-07 14:44:29 +00:00
namespace Symfony\Component\DependencyInjection ;
class Alias
{
2011-03-11 13:50:46 +00:00
private $id ;
private $public ;
2011-01-07 14:44:29 +00:00
2011-02-13 18:06:41 +00:00
/**
2014-11-30 13:33:44 +00:00
* @ param string $id Alias identifier
* @ param bool $public If this alias is public
2011-02-13 18:06:41 +00:00
*/
2011-01-07 14:44:29 +00:00
public function __construct ( $id , $public = true )
{
2017-01-10 07:04:52 +00:00
if ( ! is_string ( $id )) {
$type = is_object ( $id ) ? get_class ( $id ) : gettype ( $id );
$id = ( string ) $id ;
@ trigger_error ( sprintf ( 'Non-string identifiers are deprecated since Symfony 3.3 and won\'t be supported in 4.0 for Alias to "%s" ("%s" given.) Cast it to string beforehand.' , $id , $type ), E_USER_DEPRECATED );
}
$this -> id = $id ;
2011-01-07 14:44:29 +00:00
$this -> public = $public ;
}
2011-02-13 18:06:41 +00:00
/**
* Checks if this DI Alias should be public or not .
*
2014-04-16 11:30:19 +01:00
* @ return bool
2011-02-13 18:06:41 +00:00
*/
2011-01-07 14:44:29 +00:00
public function isPublic ()
{
return $this -> public ;
}
2011-02-13 18:06:41 +00:00
/**
* Sets if this Alias is public .
*
2014-11-30 13:33:44 +00:00
* @ param bool $boolean If this Alias should be public
2011-02-13 18:06:41 +00:00
*/
2011-01-07 14:44:29 +00:00
public function setPublic ( $boolean )
{
2014-04-12 18:44:00 +01:00
$this -> public = ( bool ) $boolean ;
2011-01-07 14:44:29 +00:00
}
2011-02-13 18:06:41 +00:00
/**
* Returns the Id of this alias .
*
* @ return string The alias id
*/
2011-01-07 14:44:29 +00:00
public function __toString ()
{
return $this -> id ;
}
2011-03-11 13:50:46 +00:00
}