Completed
Push — master ( c13142...c0435c )
by Tobias
02:34
created

CustomerCollection::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 4
Ratio 100 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 4
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Billogram\Model\Customer;
6
7
use Billogram\Model\CreatableFromArray;
8
9
/**
10
 * @author Ibrahim Hizeoui <[email protected]>
11
 */
12 View Code Duplication
class CustomerCollection 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...
13
{
14
    /**
15
     * @var Customer[]
16
     */
17
    private $customers;
18
19 1
    private function __construct(array $customers)
20
    {
21 1
        $this->customers = $customers;
22 1
    }
23
24 1
    public static function createFromArray(array $data)
25
    {
26 1
        $customers = [];
27 1
        if (isset($data['data'])) {
28 1
            foreach ($data['data'] as $item) {
29 1
                $customers[] = Customer::createFromArray(['data' => $item]);
30
            }
31
        }
32
33 1
        return new self($customers);
34
    }
35
36
    /**
37
     * @return Customer[]
38
     */
39
    public function getCustomer()
40
    {
41
        return $this->customers;
42
    }
43
}
44