Alias.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\DependencyInjection;
  11. /**
  12. * @api
  13. */
  14. class Alias
  15. {
  16. private $id;
  17. private $public;
  18. /**
  19. * Constructor.
  20. *
  21. * @param string $id Alias identifier
  22. * @param Boolean $public If this alias is public
  23. *
  24. * @api
  25. */
  26. public function __construct($id, $public = true)
  27. {
  28. $this->id = strtolower($id);
  29. $this->public = $public;
  30. }
  31. /**
  32. * Checks if this DI Alias should be public or not.
  33. *
  34. * @return Boolean
  35. *
  36. * @api
  37. */
  38. public function isPublic()
  39. {
  40. return $this->public;
  41. }
  42. /**
  43. * Sets if this Alias is public.
  44. *
  45. * @param Boolean $boolean If this Alias should be public
  46. *
  47. * @api
  48. */
  49. public function setPublic($boolean)
  50. {
  51. $this->public = (Boolean) $boolean;
  52. }
  53. /**
  54. * Returns the Id of this alias.
  55. *
  56. * @return string The alias id
  57. *
  58. * @api
  59. */
  60. public function __toString()
  61. {
  62. return $this->id;
  63. }
  64. }