1 | <?php |
||
29 | class Writer implements WriterContract |
||
30 | { |
||
31 | /** |
||
32 | * The number of frames if no verbosity is specified. |
||
33 | */ |
||
34 | const VERBOSITY_NORMAL_FRAMES = 1; |
||
35 | |||
36 | /** |
||
37 | * Holds an instance of the solutions repository. |
||
38 | * |
||
39 | * @var \NunoMaduro\Collision\Contracts\SolutionsRepository |
||
40 | */ |
||
41 | private $solutionsRepository; |
||
42 | |||
43 | /** |
||
44 | * Holds an instance of the Output. |
||
45 | * |
||
46 | * @var \Symfony\Component\Console\Output\OutputInterface |
||
47 | */ |
||
48 | protected $output; |
||
49 | |||
50 | /** |
||
51 | * Holds an instance of the Argument Formatter. |
||
52 | * |
||
53 | * @var \NunoMaduro\Collision\Contracts\ArgumentFormatter |
||
54 | */ |
||
55 | protected $argumentFormatter; |
||
56 | |||
57 | /** |
||
58 | * Holds an instance of the Highlighter. |
||
59 | * |
||
60 | * @var \NunoMaduro\Collision\Contracts\Highlighter |
||
61 | */ |
||
62 | protected $highlighter; |
||
63 | |||
64 | /** |
||
65 | * Ignores traces where the file string matches one |
||
66 | * of the provided regex expressions. |
||
67 | * |
||
68 | * @var string[] |
||
69 | */ |
||
70 | protected $ignore = []; |
||
71 | |||
72 | /** |
||
73 | * Declares whether or not the trace should appear. |
||
74 | * |
||
75 | * @var bool |
||
76 | */ |
||
77 | protected $showTrace = true; |
||
78 | |||
79 | /** |
||
80 | * Declares whether or not the editor should appear. |
||
81 | * |
||
82 | * @var bool |
||
83 | */ |
||
84 | protected $showEditor = true; |
||
85 | |||
86 | /** |
||
87 | * Creates an instance of the writer. |
||
88 | * |
||
89 | * @param \NunoMaduro\Collision\Contracts\SolutionsRepository|null $solutionsRepository |
||
90 | * @param \Symfony\Component\Console\Output\OutputInterface|null $output |
||
91 | * @param \NunoMaduro\Collision\Contracts\ArgumentFormatter|null $argumentFormatter |
||
92 | * @param \NunoMaduro\Collision\Contracts\Highlighter|null $highlighter |
||
93 | */ |
||
94 | 14 | public function __construct( |
|
105 | |||
106 | /** |
||
107 | * {@inheritdoc} |
||
108 | */ |
||
109 | 5 | public function write(Inspector $inspector): void |
|
129 | |||
130 | /** |
||
131 | * {@inheritdoc} |
||
132 | */ |
||
133 | 1 | public function ignoreFilesIn(array $ignore): WriterContract |
|
139 | |||
140 | /** |
||
141 | * {@inheritdoc} |
||
142 | */ |
||
143 | 1 | public function showTrace(bool $show): WriterContract |
|
149 | |||
150 | /** |
||
151 | * {@inheritdoc} |
||
152 | */ |
||
153 | 1 | public function showEditor(bool $show): WriterContract |
|
159 | |||
160 | /** |
||
161 | * {@inheritdoc} |
||
162 | */ |
||
163 | 2 | public function setOutput(OutputInterface $output): WriterContract |
|
169 | |||
170 | /** |
||
171 | * {@inheritdoc} |
||
172 | */ |
||
173 | 7 | public function getOutput(): OutputInterface |
|
177 | |||
178 | /** |
||
179 | * Returns pertinent frames. |
||
180 | * |
||
181 | * @param \Whoops\Exception\Inspector $inspector |
||
182 | * |
||
183 | * @return array |
||
184 | */ |
||
185 | 5 | protected function getFrames(Inspector $inspector): array |
|
201 | |||
202 | /** |
||
203 | * Renders the title of the exception. |
||
204 | * |
||
205 | * @param \Whoops\Exception\Inspector $inspector |
||
206 | * |
||
207 | * @return \NunoMaduro\Collision\Contracts\Writer |
||
208 | */ |
||
209 | 5 | protected function renderTitle(Inspector $inspector): WriterContract |
|
221 | |||
222 | /** |
||
223 | * Renders the solution of the exception, if any. |
||
224 | * |
||
225 | * @param \Whoops\Exception\Inspector $inspector |
||
226 | * |
||
227 | * @return \NunoMaduro\Collision\Contracts\Writer |
||
228 | */ |
||
229 | 5 | protected function renderSolution(Inspector $inspector): WriterContract |
|
254 | |||
255 | /** |
||
256 | * Renders the editor containing the code that was the |
||
257 | * origin of the exception. |
||
258 | * |
||
259 | * @param \Whoops\Exception\Frame $frame |
||
260 | * |
||
261 | * @return \NunoMaduro\Collision\Contracts\Writer |
||
262 | */ |
||
263 | 4 | protected function renderEditor(Frame $frame): WriterContract |
|
275 | |||
276 | /** |
||
277 | * Renders the trace of the exception. |
||
278 | * |
||
279 | * @param array $frames |
||
280 | * |
||
281 | * @return \NunoMaduro\Collision\Contracts\Writer |
||
282 | */ |
||
283 | 4 | protected function renderTrace(array $frames): WriterContract |
|
328 | |||
329 | /** |
||
330 | * Renders an message into the console. |
||
331 | * |
||
332 | * @param string $message |
||
333 | * @param bool $break |
||
334 | * |
||
335 | * @return $this |
||
336 | */ |
||
337 | 5 | protected function render(string $message, bool $break = true): WriterContract |
|
347 | |||
348 | /** |
||
349 | * Returns the relative path of the given file path. |
||
350 | * |
||
351 | * @param string $filePath |
||
352 | * |
||
353 | * @return string |
||
354 | */ |
||
355 | 5 | protected function getFileRelativePath(string $filePath): string |
|
365 | } |
||
366 |