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 | * TaskRunner constructor. |
||
24 | * |
||
25 | * @param array $filters |
||
26 | * @param Locator $locator |
||
27 | */ |
||
28 | public function __construct(array $filters, Locator $locator) |
||
33 | |||
34 | /** |
||
35 | * Run a task, load its sources before and call the clean method on the filter. |
||
36 | * |
||
37 | * @param Task $task |
||
38 | * @throws Exception |
||
39 | */ |
||
40 | public function run(Task $task) |
||
75 | |||
76 | /** |
||
77 | * Return a filter by its name. Throw an exception if it is not exists. |
||
78 | * |
||
79 | * @param string $name |
||
80 | * @return FilterInterface |
||
81 | * @throws Exception |
||
82 | */ |
||
83 | protected function getFilter($name) |
||
92 | |||
93 | /** |
||
94 | * Fetch the source files from the task and return and array of SplInfo. |
||
95 | * |
||
96 | * @param Task $task |
||
97 | * @return array |
||
98 | */ |
||
99 | protected function fetchSources(Task $task) |
||
110 | |||
111 | /** |
||
112 | * Fetch the destination files from the task and return and array of SplInfo. |
||
113 | * |
||
114 | * @param Task $task |
||
115 | * @return array |
||
116 | */ |
||
117 | protected function fetchDestinations(Task $task) |
||
131 | |||
132 | /** |
||
133 | * Filter only the sources supported by the current filter. |
||
134 | * |
||
135 | * @param SplFileInfo[] $sources |
||
136 | * @param FilterInterface $filter |
||
137 | * @return array |
||
138 | */ |
||
139 | protected function filterSources(array $sources, FilterInterface $filter) |
||
157 | |||
158 | /** |
||
159 | * Remove the filtered files from the sources, and merge with the new ones. |
||
160 | * |
||
161 | * @param SplFileInfo[] $originalSources |
||
162 | * @param SplFileInfo[] $filteredSources |
||
163 | * @param SplFileInfo[] $updatedSources |
||
164 | * @return SplFileInfo[] |
||
165 | * @throws Exception |
||
166 | */ |
||
167 | protected function updateSources(array $originalSources, array $filteredSources, array $updatedSources) |
||
191 | } |
||
192 |