Collection.php
| 1 | <?php |
| 2 | |
| 3 | namespace Give\Framework\FieldsAPI\Contracts; |
| 4 | |
| 5 | use Give\Framework\FieldsAPI\Exceptions\ReferenceNodeNotFoundException; |
| 6 | use Give\Framework\FieldsAPI\Field; |
| 7 | |
| 8 | interface Collection { |
| 9 | |
| 10 | /** |
| 11 | * Fluently append nodes to the collection. |
| 12 | * |
| 13 | * @param Node ...$nodes |
| 14 | * |
| 15 | * @return $this |
| 16 | */ |
| 17 | public function append( Node ...$nodes ); |
| 18 | |
| 19 | /** |
| 20 | * Fluently remove a named node. |
| 21 | * |
| 22 | * @param string $name |
| 23 | * |
| 24 | * @return mixed |
| 25 | */ |
| 26 | public function remove( $name ); |
| 27 | |
| 28 | /** |
| 29 | * Get all the nodes. |
| 30 | * |
| 31 | * @return Node[] |
| 32 | */ |
| 33 | public function all(); |
| 34 | |
| 35 | /** |
| 36 | * Count all the nodes. |
| 37 | * |
| 38 | * @return int |
| 39 | */ |
| 40 | public function count(); |
| 41 | |
| 42 | /** |
| 43 | * Get a node’s index by its name. |
| 44 | * |
| 45 | * @param string $name |
| 46 | * |
| 47 | * @return int |
| 48 | */ |
| 49 | public function getNodeIndexByName( $name ); |
| 50 | |
| 51 | /** |
| 52 | * Get a node by its name. |
| 53 | * |
| 54 | * @param string $name |
| 55 | * |
| 56 | * @return Node|Collection |
| 57 | */ |
| 58 | public function getNodeByName( $name ); |
| 59 | |
| 60 | /** |
| 61 | * Get only the field nodes. |
| 62 | * |
| 63 | * @return Field[] |
| 64 | */ |
| 65 | public function getFields(); |
| 66 | |
| 67 | /** |
| 68 | * @param string $siblingName |
| 69 | * @param Node $node |
| 70 | * |
| 71 | * @return $this |
| 72 | */ |
| 73 | public function insertAfter( $siblingName, Node $node ); |
| 74 | |
| 75 | /** |
| 76 | * @param string $siblingName |
| 77 | * @param Node $node |
| 78 | * |
| 79 | * @return $this |
| 80 | */ |
| 81 | public function insertBefore( $siblingName, Node $node ); |
| 82 | |
| 83 | /** |
| 84 | * Walk through each node in the collection |
| 85 | * |
| 86 | * @param callable $callback |
| 87 | * |
| 88 | * @return void |
| 89 | */ |
| 90 | public function walk( callable $callback ); |
| 91 | } |
| 92 |