Completed
Push — master ( 4b89b9...dd9abc )
by Jens
10:35
created

DeliveryItemCollection::indexRow()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 10
Code Lines 7

Duplication

Lines 10
Ratio 100 %

Code Coverage

Tests 8
CRAP Score 4

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 10
loc 10
ccs 8
cts 8
cp 1
rs 9.2
cc 4
eloc 7
nc 4
nop 2
crap 4
1
<?php
2
/**
3
 * @author @jayS-de <[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://dev.commercetools.com/http-api-projects-orders.html#delivery-item
13
 * @method DeliveryItem current()
14
 * @method DeliveryItemCollection add(DeliveryItem $element)
15
 * @method DeliveryItem getAt($offset)
16
 */
17 View Code Duplication
class DeliveryItemCollection extends Collection
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...
18
{
19
    protected $type = '\Commercetools\Core\Model\Order\DeliveryItem';
20
21 1
    protected function indexRow($offset, $row)
22
    {
23 1
        $id = null;
24 1
        if ($row instanceof DeliveryItem) {
25 1
            $id = $row->getId();
26 1
        } elseif (is_array($row)) {
27 1
            $id = isset($row[static::ID]) ? $row[static::ID] : null;
28
        }
29 1
        $this->addToIndex(static::ID, $offset, $id);
30 1
    }
31
}
32