1 | <?php |
||
26 | class Edge |
||
27 | { |
||
28 | use Attributes; |
||
29 | |||
30 | /** @var Node Node from where to link */ |
||
31 | private $from; |
||
32 | |||
33 | /** @var Node Node where to to link */ |
||
34 | private $to; |
||
35 | |||
36 | /** |
||
37 | * Creates a new Edge / Link between the given nodes. |
||
38 | * |
||
39 | * @param Node $from Starting node to create an Edge from. |
||
40 | * @param Node $to Destination node where to create and |
||
41 | * edge to. |
||
42 | */ |
||
43 | 1 | public function __construct(Node $from, Node $to) |
|
48 | |||
49 | /** |
||
50 | * Factory method used to assist with fluent interface handling. |
||
51 | * |
||
52 | * See the examples for more details. |
||
53 | * |
||
54 | * @param Node $from Starting node to create an Edge from. |
||
55 | * @param Node $to Destination node where to create and |
||
56 | * edge to. |
||
57 | */ |
||
58 | 1 | public static function create(Node $from, Node $to) : self |
|
62 | |||
63 | /** |
||
64 | * Returns the source Node for this Edge. |
||
65 | */ |
||
66 | 1 | public function getFrom() : Node |
|
70 | |||
71 | /** |
||
72 | * Returns the destination Node for this Edge. |
||
73 | */ |
||
74 | 1 | public function getTo() : Node |
|
78 | |||
79 | /** |
||
80 | * Magic method to provide a getter/setter to add attributes on the edge. |
||
81 | * |
||
82 | * Using this method we make sure that we support any attribute without too |
||
83 | * much hassle. If the name for this method does not start with get or set |
||
84 | * we return null. |
||
85 | * |
||
86 | * Set methods return this graph (fluent interface) whilst get methods |
||
87 | * return the attribute value. |
||
88 | * |
||
89 | * @param string $name name of the invoked method, expect it to be |
||
90 | * setX or getX. |
||
91 | * @param mixed[] $arguments Arguments for the setter, only 1 is expected: value |
||
92 | * |
||
93 | * @return Attribute|Edge|null |
||
94 | * |
||
95 | * @throws AttributeNotFound |
||
96 | */ |
||
97 | 1 | public function __call(string $name, array $arguments) |
|
110 | |||
111 | /** |
||
112 | * Returns the edge definition as is requested by GraphViz. |
||
113 | */ |
||
114 | 1 | public function __toString() : string |
|
132 | } |
||
133 |