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

src/Model/Customer/CustomerCollection.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

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
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