Passed
Push — develop ( 818a9c...df7c09 )
by Jens
14:52
created

DeliveryItemCollection   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
eloc 8
dl 0
loc 13
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A indexRow() 0 9 4
1
<?php
2
/**
3
 * @author @jenschude <[email protected]>
4
 */
5
6
namespace Commercetools\Core\Model\Order;
7
8
use Commercetools\Core\Model\Common\Collection;
9
10
/**
11
 * @package Commercetools\Core\Model\Order
12
 * @link https://docs.commercetools.com/http-api-projects-orders.html#deliveryitem
13
 * @method DeliveryItem current()
14
 * @method DeliveryItemCollection add(DeliveryItem $element)
15
 * @method DeliveryItem getAt($offset)
16
 * @method DeliveryItem getById($offset)
17
 */
18
class DeliveryItemCollection extends Collection
19
{
20
    protected $type = DeliveryItem::class;
21
22 18
    protected function indexRow($offset, $row)
23
    {
24 18
        $id = null;
25 18
        if ($row instanceof DeliveryItem) {
26 18
            $id = $row->getId();
27 12
        } elseif (is_array($row)) {
28 12
            $id = isset($row[static::ID]) ? $row[static::ID] : null;
29
        }
30 18
        $this->addToIndex(static::ID, $offset, $id);
31 18
    }
32
}
33