Test Failed
Push — develop ( e9b95f...6f35c3 )
by Jens
09:15
created

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