Code Duplication    Length = 32-32 lines in 3 locations

src/Model/Customer/CustomerCollection.php 1 location

@@ 12-43 (lines=32) @@
9
/**
10
 * @author Ibrahim Hizeoui <[email protected]>
11
 */
12
class CustomerCollection implements CreatableFromArray
13
{
14
    /**
15
     * @var Customer[]
16
     */
17
    private $customers;
18
19
    /**
20
     * @param Customer[] $customers
21
     */
22
    private function __construct(array $customers)
23
    {
24
        $this->customers = $customers;
25
    }
26
27
    public static function createFromArray(array $data)
28
    {
29
        $customers = [];
30
        if (isset($data['data'])) {
31
            foreach ($data['data'] as $item) {
32
                $customers[] = Customer::createFromArray(['data' => $item]);
33
            }
34
        }
35
36
        return new self($customers);
37
    }
38
39
    /**
40
     * @return Customer[]
41
     */
42
    public function getCustomers()
43
    {
44
        return $this->customers;
45
    }
46
}

src/Model/Invoice/InvoiceCollection.php 1 location

@@ 12-43 (lines=32) @@
9
/**
10
 * @author Ibrahim Hizeoui <[email protected]>
11
 */
12
class InvoiceCollection implements CreatableFromArray
13
{
14
    /**
15
     * @var Invoice[]
16
     */
17
    private $invoices;
18
19
    /**
20
     * @param Invoice[] $invoices
21
     */
22
    private function __construct(array $invoices)
23
    {
24
        $this->invoices = $invoices;
25
    }
26
27
    public static function createFromArray(array $data)
28
    {
29
        $invoices = [];
30
        if (isset($data['data'])) {
31
            foreach ($data['data'] as $item) {
32
                $invoices[] = Invoice::createFromArray(['data' => $item]);
33
            }
34
        }
35
36
        return new self($invoices);
37
    }
38
39
    /**
40
     * @return Invoice[]
41
     */
42
    public function getInvoices()
43
    {
44
        return $this->invoices;
45
    }
46
}

src/Model/Report/ReportCollection.php 1 location

@@ 9-40 (lines=32) @@
6
7
use Billogram\Model\CreatableFromArray;
8
9
class ReportCollection implements CreatableFromArray
10
{
11
    /**
12
     * @var Report[]
13
     */
14
    private $reports;
15
16
    /**
17
     * @param Report[] $reports
18
     */
19
    private function __construct(array $reports)
20
    {
21
        $this->reports = $reports;
22
    }
23
24
    public static function createFromArray(array $data)
25
    {
26
        $reports = [];
27
        if (isset($data['data'])) {
28
            foreach ($data['data'] as $report) {
29
                $reports[] = Report::createFromArray(['data' => $report]);
30
            }
31
        }
32
33
        return new self($reports);
34
    }
35
36
    /**
37
     * @return Report[]
38
     */
39
    public function getReports()
40
    {
41
        return $this->reports;
42
    }
43
}