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

CustomerCollection   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 32
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 81.82%

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 1
dl 32
loc 32
ccs 9
cts 11
cp 0.8182
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 4 4 1
A createFromArray() 11 11 3
A getCustomer() 4 4 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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