ServiceReferenceGraphEdge.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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\Compiler;
  11. /**
  12. * Represents an edge in your service graph.
  13. *
  14. * Value is typically a reference.
  15. *
  16. * @author Johannes M. Schmitt <schmittjoh@gmail.com>
  17. */
  18. class ServiceReferenceGraphEdge
  19. {
  20. private $sourceNode;
  21. private $destNode;
  22. private $value;
  23. private $lazy;
  24. private $weak;
  25. private $byConstructor;
  26. public function __construct(ServiceReferenceGraphNode $sourceNode, ServiceReferenceGraphNode $destNode, $value = null, bool $lazy = false, bool $weak = false, bool $byConstructor = false)
  27. {
  28. $this->sourceNode = $sourceNode;
  29. $this->destNode = $destNode;
  30. $this->value = $value;
  31. $this->lazy = $lazy;
  32. $this->weak = $weak;
  33. $this->byConstructor = $byConstructor;
  34. }
  35. /**
  36. * Returns the value of the edge.
  37. *
  38. * @return mixed
  39. */
  40. public function getValue()
  41. {
  42. return $this->value;
  43. }
  44. /**
  45. * Returns the source node.
  46. *
  47. * @return ServiceReferenceGraphNode
  48. */
  49. public function getSourceNode()
  50. {
  51. return $this->sourceNode;
  52. }
  53. /**
  54. * Returns the destination node.
  55. *
  56. * @return ServiceReferenceGraphNode
  57. */
  58. public function getDestNode()
  59. {
  60. return $this->destNode;
  61. }
  62. /**
  63. * Returns true if the edge is lazy, meaning it's a dependency not requiring direct instantiation.
  64. *
  65. * @return bool
  66. */
  67. public function isLazy()
  68. {
  69. return $this->lazy;
  70. }
  71. /**
  72. * Returns true if the edge is weak, meaning it shouldn't prevent removing the target service.
  73. *
  74. * @return bool
  75. */
  76. public function isWeak()
  77. {
  78. return $this->weak;
  79. }
  80. /**
  81. * Returns true if the edge links with a constructor argument.
  82. *
  83. * @return bool
  84. */
  85. public function isReferencedByConstructor()
  86. {
  87. return $this->byConstructor;
  88. }
  89. }