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

Reportable   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 4
eloc 8
dl 0
loc 33
c 0
b 0
f 0
ccs 0
cts 9
cp 0
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A meetConditions() 0 2 1
A beforeReport() 0 2 1
A report() 0 10 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