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 | 1 | * TaskRunner constructor. |
|
29 | * |
||
30 | 1 | * @param FilterInterface[] $filters |
|
31 | 1 | * @param Locator $locator |
|
32 | 1 | * @param bool $isDebug |
|
33 | */ |
||
34 | public function __construct(array $filters, Locator $locator, $isDebug = false) |
||
40 | 1 | ||
41 | /** |
||
42 | * Run a task, load its sources before and call the clean method on the filter. |
||
43 | * |
||
44 | 1 | * @param Task $task |
|
45 | 1 | * @throws Exception |
|
46 | */ |
||
47 | public function run(Task $task) |
||
85 | |||
86 | /** |
||
87 | 1 | * 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 | protected function getFilter($name) |
||
102 | 1 | ||
103 | 1 | /** |
|
104 | * Fetch the source files from the task and return and array of SplInfo. |
||
105 | 1 | * |
|
106 | * @param Task $task |
||
107 | * @return array |
||
108 | */ |
||
109 | protected function fetchSources(Task $task) |
||
120 | 1 | ||
121 | 1 | /** |
|
122 | * Fetch the destination files from the task and return and array of SplInfo. |
||
123 | 1 | * |
|
124 | * @param Task $task |
||
125 | * @return SplFileInfo[] |
||
126 | */ |
||
127 | protected function fetchDestinations(Task $task) |
||
138 | |||
139 | 1 | /** |
|
140 | 1 | * Filter only the sources supported by the current filter. |
|
141 | * |
||
142 | * @param SplFileInfo[] $sources |
||
143 | * @param FilterInterface $filter |
||
144 | 1 | * @return array |
|
145 | 1 | * @throws Exception |
|
146 | */ |
||
147 | protected function filterSources(array $sources, FilterInterface $filter) |
||
170 | |||
171 | /** |
||
172 | 1 | * Remove the filtered files from the sources, and merge with the new ones. |
|
173 | * |
||
174 | 1 | * @param SplFileInfo[] $originalSources |
|
175 | * @param SplFileInfo[] $filteredSources |
||
176 | * @param SplFileInfo[] $updatedSources |
||
177 | 1 | * @return SplFileInfo[] |
|
178 | * @throws Exception |
||
179 | 1 | */ |
|
180 | 1 | protected function updateSources(array $originalSources, array $filteredSources, array $updatedSources) |
|
209 | } |
||
210 |