vendor/symfony/src/Symfony/Component/DependencyInjection/Compiler/ServiceReferenceGraphNode.php
changeset 0 7f95f8617b0b
equal deleted inserted replaced
-1:000000000000 0:7f95f8617b0b
       
     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\Compiler;
       
    13 
       
    14 use Symfony\Component\DependencyInjection\Definition;
       
    15 use Symfony\Component\DependencyInjection\Alias;
       
    16 
       
    17 /**
       
    18  * Represents a node in your service graph.
       
    19  *
       
    20  * Value is typically a definition, or an alias.
       
    21  *
       
    22  * @author Johannes M. Schmitt <schmittjoh@gmail.com>
       
    23  */
       
    24 class ServiceReferenceGraphNode
       
    25 {
       
    26     private $id;
       
    27     private $inEdges;
       
    28     private $outEdges;
       
    29     private $value;
       
    30 
       
    31     /**
       
    32      * Constructor.
       
    33      *
       
    34      * @param string $id The node identifier
       
    35      * @param mixed $value The node value
       
    36      */
       
    37     public function __construct($id, $value)
       
    38     {
       
    39         $this->id = $id;
       
    40         $this->value = $value;
       
    41         $this->inEdges = array();
       
    42         $this->outEdges = array();
       
    43     }
       
    44 
       
    45     /**
       
    46      * Adds an in edge to this node.
       
    47      *
       
    48      * @param ServiceReferenceGraphEdge $edge
       
    49      */
       
    50     public function addInEdge(ServiceReferenceGraphEdge $edge)
       
    51     {
       
    52         $this->inEdges[] = $edge;
       
    53     }
       
    54 
       
    55     /**
       
    56      * Adds an out edge to this node.
       
    57      *
       
    58      * @param ServiceReferenceGraphEdge $edge
       
    59      */
       
    60     public function addOutEdge(ServiceReferenceGraphEdge $edge)
       
    61     {
       
    62         $this->outEdges[] = $edge;
       
    63     }
       
    64 
       
    65     /**
       
    66      * Checks if the value of this node is an Alias.
       
    67      *
       
    68      * @return Boolean True if the value is an Alias instance
       
    69      */
       
    70     public function isAlias()
       
    71     {
       
    72         return $this->value instanceof Alias;
       
    73     }
       
    74 
       
    75     /**
       
    76      * Checks if the value of this node is a Definition.
       
    77      *
       
    78      * @return Boolean True if the value is a Definition instance
       
    79      */
       
    80     public function isDefinition()
       
    81     {
       
    82         return $this->value instanceof Definition;
       
    83     }
       
    84 
       
    85     /**
       
    86      * Returns the identifier.
       
    87      *
       
    88      * @return string
       
    89      */
       
    90     public function getId()
       
    91     {
       
    92         return $this->id;
       
    93     }
       
    94 
       
    95     /**
       
    96      * Returns the in edges.
       
    97      *
       
    98      * @return array The in ServiceReferenceGraphEdge array
       
    99      */
       
   100     public function getInEdges()
       
   101     {
       
   102         return $this->inEdges;
       
   103     }
       
   104 
       
   105     /**
       
   106      * Returns the out edges.
       
   107      *
       
   108      * @return array The out ServiceReferenceGraphEdge array
       
   109      */
       
   110     public function getOutEdges()
       
   111     {
       
   112         return $this->outEdges;
       
   113     }
       
   114 
       
   115     /**
       
   116      * Returns the value of this Node
       
   117      *
       
   118      * @return mixed The value
       
   119      */
       
   120     public function getValue()
       
   121     {
       
   122         return $this->value;
       
   123     }
       
   124 }