Reference.php 1008 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. * Reference represents a service reference.
  13. *
  14. * @author Fabien Potencier <fabien@symfony.com>
  15. */
  16. class Reference
  17. {
  18. private $id;
  19. private $invalidBehavior;
  20. public function __construct(string $id, int $invalidBehavior = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE)
  21. {
  22. $this->id = $id;
  23. $this->invalidBehavior = $invalidBehavior;
  24. }
  25. /**
  26. * @return string The service identifier
  27. */
  28. public function __toString()
  29. {
  30. return $this->id;
  31. }
  32. /**
  33. * Returns the behavior to be used when the service does not exist.
  34. *
  35. * @return int
  36. */
  37. public function getInvalidBehavior()
  38. {
  39. return $this->invalidBehavior;
  40. }
  41. }