1 | <?php |
||
10 | class TaskRunner |
||
11 | { |
||
12 | /** |
||
13 | * @var FilterInterface[] |
||
14 | */ |
||
15 | protected $filters; |
||
16 | |||
17 | /** |
||
18 | * @var Locator |
||
19 | */ |
||
20 | protected $locator; |
||
21 | |||
22 | /** |
||
23 | * @var bool |
||
24 | */ |
||
25 | protected $isDebug; |
||
26 | |||
27 | /** |
||
28 | * TaskRunner constructor. |
||
29 | * |
||
30 | * @param FilterInterface[] $filters |
||
31 | * @param Locator $locator |
||
32 | * @param bool $isDebug |
||
33 | */ |
||
34 | 1 | public function __construct(array $filters, Locator $locator, $isDebug = false) |
|
40 | |||
41 | /** |
||
42 | * Run a task, load its sources before and call the clean method on the filter. |
||
43 | * |
||
44 | * @param Task $task |
||
45 | * @throws Exception |
||
46 | */ |
||
47 | 1 | public function run(Task $task) |
|
85 | |||
86 | /** |
||
87 | * Return a filter by its name. Throw an exception if it is not exists. |
||
88 | * |
||
89 | * @param string $name |
||
90 | * @return FilterInterface |
||
91 | * @throws Exception |
||
92 | */ |
||
93 | 1 | protected function getFilter($name) |
|
102 | |||
103 | /** |
||
104 | * Fetch the source files from the task and return and array of SplInfo. |
||
105 | * |
||
106 | * @param Task $task |
||
107 | * @return array |
||
108 | */ |
||
109 | 1 | protected function fetchSources(Task $task) |
|
120 | |||
121 | /** |
||
122 | * Fetch the destination files from the task and return and array of SplInfo. |
||
123 | * |
||
124 | * @param Task $task |
||
125 | * @return SplFileInfo[] |
||
126 | */ |
||
127 | 1 | protected function fetchDestinations(Task $task) |
|
138 | |||
139 | /** |
||
140 | * Filter only the sources supported by the current filter. |
||
141 | * |
||
142 | * @param SplFileInfo[] $sources |
||
143 | * @param FilterInterface $filter |
||
144 | * @return array |
||
145 | * @throws Exception |
||
146 | */ |
||
147 | 1 | protected function filterSources(array $sources, FilterInterface $filter) |
|
170 | |||
171 | /** |
||
172 | * Remove the filtered files from the sources, and merge with the new ones. |
||
173 | * |
||
174 | * @param SplFileInfo[] $originalSources |
||
175 | * @param SplFileInfo[] $filteredSources |
||
176 | * @param SplFileInfo[] $updatedSources |
||
177 | * @return SplFileInfo[] |
||
178 | * @throws Exception |
||
179 | */ |
||
180 | 1 | protected function updateSources(array $originalSources, array $filteredSources, array $updatedSources) |
|
209 | } |
||
210 |