1 | <?php |
||
12 | class HtmlOutput extends AbstractOutput implements TriggerableInterface |
||
13 | { |
||
14 | use TextTriggerTrait; |
||
15 | |||
16 | /** |
||
17 | * Plates engine used to output HTML. |
||
18 | * @var Engine Plates engine instance. |
||
19 | */ |
||
20 | protected $platesEngine; |
||
21 | |||
22 | /** |
||
23 | * @inheritdoc |
||
24 | */ |
||
25 | public function result(AnalysisResult $result) |
||
26 | { |
||
27 | $this->cli->br(); |
||
28 | $this->cli->inline('Writing HTML report in "./phphound/"... '); |
||
29 | $history = new History($this->getOutputDirectory()); |
||
30 | $history->append($result); |
||
31 | foreach ($result->toArray() as $filePath => $lines) { |
||
32 | $this->writeFileHtml($filePath, $lines); |
||
33 | } |
||
34 | $this->writeIndexHtml($result, $history); |
||
35 | $history->save(); |
||
36 | $this->cli->out('Done!'); |
||
37 | } |
||
38 | |||
39 | /** |
||
40 | * Create HTML report index page. |
||
41 | * @param AnalysisResult $result result data object. |
||
42 | * @return void |
||
43 | */ |
||
44 | protected function writeIndexHtml(AnalysisResult $result, History $history) |
||
71 | |||
72 | /** |
||
73 | * Create HTML report for one file. |
||
74 | * @param string $phpFilePath analyzed PHP file path. |
||
75 | * @param array $lines lines with their issues. |
||
76 | * @return void |
||
77 | */ |
||
78 | protected function writeFileHtml($phpFilePath, $lines) |
||
96 | |||
97 | /** |
||
98 | * Render a HTML view within the layout. |
||
99 | * @param string $view view file name. |
||
100 | * @param array $data variables required by view file. |
||
101 | * @return string output HTML. |
||
102 | */ |
||
103 | protected function renderView($view, $data) |
||
119 | |||
120 | /** |
||
121 | * Configure and return Plates engine. |
||
122 | * @return Engine Plates engine instance. |
||
123 | */ |
||
124 | protected function getPlatesEngine() |
||
132 | |||
133 | /** |
||
134 | * Get output directory. |
||
135 | * @return string output directory path. |
||
136 | */ |
||
137 | protected function getOutputDirectory() |
||
147 | } |
||
148 |