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

ParcelCollection::indexRow()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 4

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 9
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0
cc 4
nc 4
nop 2
crap 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#parcel
13
 * @method Parcel current()
14
 * @method ParcelCollection add(Parcel $element)
15
 * @method Parcel getAt($offset)
16
 * @method Parcel getById($offset)
17
 */
18
class ParcelCollection extends Collection
19
{
20
    protected $type = Parcel::class;
21
22 12
    protected function indexRow($offset, $row)
23
    {
24 12
        $id = null;
25 12
        if ($row instanceof Parcel) {
26 10
            $id = $row->getId();
27 12
        } elseif (is_array($row)) {
28 12
            $id = isset($row[static::ID]) ? $row[static::ID] : null;
29
        }
30 12
        $this->addToIndex(static::ID, $offset, $id);
31 12
    }
32
}
33