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

InvoiceCollection::createFromArray()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 11
Code Lines 6

Duplication

Lines 11
Ratio 100 %

Code Coverage

Tests 6
CRAP Score 3

Importance

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