Completed
Push — develop ( fe1195...b733eb )
by Alec
05:48
created

Reportable   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 23
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getReport() 0 8 2
A prepareForReport() 0 2 1
1
<?php
2
/**
3
 * User: alec
4
 * Date: 01.12.18
5
 * Time: 20:25
6
 */
7
8
namespace AlecRabbit\Tools\Reports\Traits;
9
10
use AlecRabbit\Tools\Reports\Contracts\ReportInterface;
11
use AlecRabbit\Tools\Reports\Factory;
12
13
trait Reportable
14
{
15
    /** @var ReportInterface */
16
    protected $reportObject;
17
18
    /**
19
     * @return ReportInterface
20
     */
21 9
    public function getReport(): ReportInterface
22
    {
23 9
        if (null === $this->reportObject) {
24 9
            $this->prepareForReport();
25 9
            $this->reportObject = Factory::makeReport($this);
0 ignored issues
show
Bug introduced by
$this of type AlecRabbit\Tools\Reports\Traits\Reportable is incompatible with the type AlecRabbit\Tools\Reports...cts\ReportableInterface expected by parameter $reportable of AlecRabbit\Tools\Reports\Factory::makeReport(). ( Ignorable by Annotation )

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

25
            $this->reportObject = Factory::makeReport(/** @scrutinizer ignore-type */ $this);
Loading history...
26
        }
27
        return
28 9
            $this->reportObject;
29
    }
30
31
    /**
32
     * Makes all necessary actions before report
33
     */
34 7
    protected function prepareForReport(): void
35
    {
36 7
    }
37
}
38