Total Complexity | 7 |
Total Lines | 48 |
Duplicated Lines | 0 % |
Coverage | 93.75% |
Changes | 0 |
1 | <?php declare(strict_types=1); |
||
8 | abstract class Reportable implements ReportableInterface |
||
9 | { |
||
10 | /** @var ReportInterface */ |
||
11 | protected $report; |
||
12 | |||
13 | /** |
||
14 | * @param bool $rebuild Rebuild report object |
||
15 | * @return ReportInterface |
||
16 | */ |
||
17 | 1 | public function report(bool $rebuild = true): ReportInterface |
|
18 | { |
||
19 | 1 | $rebuild = $this->checkReport() || $rebuild; |
|
20 | 1 | if (true === $rebuild) { |
|
21 | 1 | $this->checkConditions(); |
|
22 | 1 | $this->beforeReport(); |
|
23 | /** @noinspection PhpParamsInspection */ |
||
24 | 1 | $this->report->buildOn($this); |
|
25 | } |
||
26 | return |
||
27 | 1 | $this->report; |
|
28 | } |
||
29 | |||
30 | /** |
||
31 | * Checks if all conditions needed for report are met |
||
32 | */ |
||
33 | 1 | protected function checkConditions(): void |
|
34 | { |
||
35 | 1 | } |
|
36 | |||
37 | /** |
||
38 | * Makes all necessary actions before report |
||
39 | */ |
||
40 | 1 | protected function beforeReport(): void |
|
41 | { |
||
42 | 1 | } |
|
43 | |||
44 | abstract protected function createEmptyReport(): ReportInterface; |
||
45 | |||
46 | /** |
||
47 | * @return bool |
||
48 | */ |
||
49 | 1 | protected function checkReport(): bool |
|
56 | } |
||
57 | } |
||
58 |