1 | <?php |
||
18 | class Producer |
||
19 | { |
||
20 | |||
21 | const ERROR_CONFIG_WITH_EMPTY_TASK = 'Config with empty task'; |
||
22 | const PLACEHOLDER_TASK_SUCCESS = ' + Ok :'; |
||
23 | const PLACEHOLDER_TASK_FAIL = ' - Fail :'; |
||
24 | const PLACEHOLDER_TASK_ERROR = ' - Error :'; |
||
25 | |||
26 | /** |
||
27 | * @var array |
||
28 | */ |
||
29 | protected $taskSet = []; |
||
30 | |||
31 | /** |
||
32 | * @var AbstractChecker[] |
||
33 | */ |
||
34 | protected $checkerSet = []; |
||
35 | |||
36 | /** |
||
37 | * @var AbstractOutput |
||
38 | */ |
||
39 | protected $outputHandler; |
||
40 | |||
41 | /** |
||
42 | * @var array |
||
43 | */ |
||
44 | protected $taskFail = []; |
||
45 | |||
46 | /** |
||
47 | * @var array |
||
48 | */ |
||
49 | protected $taskError = []; |
||
50 | |||
51 | /** |
||
52 | * @var array |
||
53 | */ |
||
54 | protected $taskSuccess = []; |
||
55 | |||
56 | /** |
||
57 | * Producer constructor. |
||
58 | * |
||
59 | * @param array $taskSet |
||
60 | */ |
||
61 | public function __construct(array $taskSet = []) |
||
65 | |||
66 | /** |
||
67 | * @param array $taskSet |
||
68 | * |
||
69 | * @return $this |
||
70 | */ |
||
71 | public function setTaskSet(array $taskSet) |
||
77 | |||
78 | /** |
||
79 | * @param AbstractOutput $outputHandler |
||
80 | * |
||
81 | * @return $this |
||
82 | */ |
||
83 | public function setOutputHandler(AbstractOutput $outputHandler) |
||
89 | |||
90 | /** |
||
91 | * @return AbstractOutput|Console |
||
92 | */ |
||
93 | public function getOutputHandler() |
||
101 | |||
102 | /** |
||
103 | * @param string $msg |
||
104 | * @param string $type |
||
105 | * |
||
106 | * @return $this |
||
107 | */ |
||
108 | public function output($msg = '', $type = AbstractOutput::TYPE_DEFAULT) |
||
114 | |||
115 | /** |
||
116 | * @return $this |
||
117 | */ |
||
118 | public function run() |
||
139 | |||
140 | /** |
||
141 | * @param $checkerAlias |
||
142 | * |
||
143 | * @return AbstractChecker |
||
144 | */ |
||
145 | public function createChecker($checkerAlias) |
||
159 | |||
160 | /** |
||
161 | * @param AbstractResultException $resultException |
||
162 | * |
||
163 | * @return $this |
||
164 | */ |
||
165 | protected function renderTask(AbstractResultException $resultException) |
||
180 | |||
181 | /** |
||
182 | * @param $text |
||
183 | * |
||
184 | * @return $this |
||
185 | */ |
||
186 | protected function renderHeader($text) |
||
196 | |||
197 | /** |
||
198 | * @return $this |
||
199 | */ |
||
200 | protected function renderStats() |
||
221 | |||
222 | /** |
||
223 | * @param array $list |
||
224 | * @param string $title |
||
225 | * |
||
226 | * @return $this |
||
227 | */ |
||
228 | protected function renderList(array $list, $title = '') |
||
254 | |||
255 | /** |
||
256 | * @param array $task |
||
257 | * |
||
258 | * @return \Exception|ErrorException|FailException|SuccessException |
||
259 | */ |
||
260 | public function runTask(array $task = []) |
||
282 | } |