Completed
Push — master ( bf6574...290f71 )
by Tobias
01:41
created

ReportCollection::getReport()   A

Complexity

Conditions 1
Paths 1

Duplication

Lines 4
Ratio 100 %

Size

Total Lines 4
Code Lines 2

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 4
loc 4
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Billogram\Model\Report;
6
7
use Billogram\Model\CreatableFromArray;
8
9 View Code Duplication
class ReportCollection implements CreatableFromArray
0 ignored issues
show
Duplication introduced by Ibrahimhizeoui
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
10
{
11
    /**
12
     * @var Report[]
13
     */
14
    private $reports;
15
16
    /**
17
     * @return Report[]
18
     */
19
    public function getReport()
20
    {
21
        return $this->reports;
22
    }
23
24 1
    private function __construct(array $reports)
25
    {
26 1
        $this->reports = $reports;
27 1
    }
28
29 1
    public static function createFromArray(array $data)
30
    {
31 1
        $reports = [];
32 1
        if (isset($data['data'])) {
33 1
            foreach ($data['data'] as $report) {
34
                $reports[] = Report::createFromArray(['data' => $report]);
35
            }
36
        }
37
38 1
        return new self($reports);
39
    }
40
}
41