1 | <?php |
||
23 | class ProcedureBuilder |
||
24 | { |
||
25 | /** |
||
26 | * @var array Definitions |
||
27 | */ |
||
28 | private $definitions; |
||
29 | |||
30 | /** |
||
31 | * @var string Current definition |
||
32 | */ |
||
33 | private $context; |
||
34 | |||
35 | 9 | public function __construct() |
|
39 | |||
40 | /** |
||
41 | * Creates a procedure. |
||
42 | * |
||
43 | * @param string $name Procedure name |
||
44 | * |
||
45 | * @return $this |
||
46 | */ |
||
47 | 9 | public function createProcedure($name) |
|
64 | |||
65 | /** |
||
66 | * Builds a procedure object. |
||
67 | * |
||
68 | * @return Procedure |
||
69 | */ |
||
70 | 9 | public function getProcedure() |
|
74 | |||
75 | /** |
||
76 | * Adds a source instruction to a procedure. |
||
77 | * |
||
78 | * @param SourceAdapterInterface|callable $adapter Source adapter |
||
79 | * @param Request $request Request sent to source adapter |
||
80 | * |
||
81 | * @return $this |
||
82 | */ |
||
83 | 3 | public function addSource($adapter, Request $request = null) |
|
96 | |||
97 | /** |
||
98 | * Adds a target instruction to a procedure. |
||
99 | * |
||
100 | * @param TargetAdapterInterface|callable $adapter Target adapter |
||
101 | * |
||
102 | * @return $this |
||
103 | */ |
||
104 | 3 | public function addTarget($adapter) |
|
113 | |||
114 | /** |
||
115 | * Adds a worker instruction to a procedure. |
||
116 | * |
||
117 | * @param WorkerInterface|callable $worker Worker |
||
118 | * |
||
119 | * @return $this |
||
120 | */ |
||
121 | 3 | public function addWorker($worker) |
|
130 | |||
131 | /** |
||
132 | * Pushes the array elements to the local storage. |
||
133 | * |
||
134 | * @return $this |
||
135 | */ |
||
136 | 1 | public function split() |
|
140 | |||
141 | /** |
||
142 | * Switches current procedure context to parent procedure. |
||
143 | * |
||
144 | * @return $this |
||
145 | */ |
||
146 | 5 | public function end() |
|
156 | |||
157 | /** |
||
158 | * Adds definition. |
||
159 | * |
||
160 | * @param string $type |
||
161 | * @param mixed $component |
||
162 | */ |
||
163 | 4 | private function addDefinition($type, $component) |
|
167 | } |
||
168 |