Completed
Push — master ( 3a0bc4...e34409 )
by Alec
10:26 queued 05:45
created

Reportable::beforeReport()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 0
dl 0
loc 2
c 0
b 0
f 0
ccs 0
cts 1
cp 0
rs 10
cc 1
nc 1
nop 0
crap 2
1
<?php declare(strict_types=1);
2
3
namespace AlecRabbit\Traits\ForReports;
4
5
use AlecRabbit\Traits\ForReports\Contracts\ReportInterface;
6
7
trait Reportable
8
{
9
    /** @var ReportInterface */
10
    protected $report;
11
12
    /**
13
     * @param bool $rebuild Rebuild report object
14
     * @return ReportInterface
15
     */
16
    public function report(bool $rebuild = true): ReportInterface
17
    {
18
        if (true === $rebuild) {
19
            $this->meetConditions();
20
            $this->beforeReport();
21
            /** @noinspection PhpParamsInspection */
22
            $this->report->buildOn($this);
1 ignored issue
show
Bug introduced by
$this of type AlecRabbit\Traits\ForReports\Reportable is incompatible with the type AlecRabbit\Traits\ForRep...cts\ReportableInterface expected by parameter $reportable of AlecRabbit\Traits\ForRep...ortInterface::buildOn(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

22
            $this->report->buildOn(/** @scrutinizer ignore-type */ $this);
Loading history...
23
        }
24
        return
25
            $this->report;
26
    }
27
28
    /**
29
     * Checks if all conditions needed for report are met
30
     */
31
    protected function meetConditions(): void
32
    {
33
    }
34
35
    /**
36
     * Makes all necessary actions before report
37
     */
38
    protected function beforeReport(): void
39
    {
40
    }
41
}
42