Completed
Push — master ( 168b8f...f2b799 )
by Tobias
02:41
created

Item   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 2
dl 0
loc 25
ccs 15
cts 15
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B createFromArray() 0 22 5
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Billogram\Model\Item;
6
7
/**
8
 * @author Ibrahim Hizeoui <[email protected]>
9
 */
10
class Item extends BaseItem
11
{
12 5
    public static function createFromArray(array $data)
13
    {
14 5
        if (array_key_exists('data', $data)) {
15 4
            $data = $data['data'];
16
        }
17
18 5
        $item = new self();
19 5
        $item->itemNo = $data['item_no'] ?? null;
20 5
        $item->title = $data['title'] ?? null;
21 5
        $item->description = $data['description'] ?? null;
22 5
        $item->price = $data['price'] ?? null;
23 5
        $item->vat = $data['vat'] ?? null;
24 5
        $item->unit = $data['unit'] ?? null;
25 5
        $item->createdAt = isset($data['created_at']) ? new \DateTime($data['created_at']) : null;
26 5
        $item->updatedAt = isset($data['updated_at']) ? new \DateTime($data['updated_at']) : null;
27
28 5
        if (array_key_exists('bookkeeping', $data)) {
29 4
            $item->bookkeeping = Bookkeeping::createFromArray($data['bookkeeping']);
30
        }
31
32 5
        return $item;
33
    }
34
}
35