Passed
Branch php-scrutinizer (0ac9d8)
by Jens
09:19
created

AssetCollection::indexRow()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 4.0466

Importance

Changes 0
Metric Value
dl 0
loc 9
ccs 6
cts 7
cp 0.8571
rs 9.2
c 0
b 0
f 0
cc 4
eloc 6
nc 4
nop 2
crap 4.0466
1
<?php
2
/**
3
 * @author @jenschude <[email protected]>
4
 */
5
6
namespace Commercetools\Core\Model\Common;
7
8
/**
9
 * @package Commercetools\Core\Model\Common
10
 *
11
 * @method AssetCollection add(Asset $element)
12
 * @method Asset current()
13
 * @method Asset getAt($offset)
14
 * @method Asset getById($offset)
15
 */
16
class AssetCollection extends Collection
17
{
18
    protected $type = Asset::class;
19
20 14
    protected function indexRow($offset, $row)
21
    {
22 14
        $id = null;
23 14
        if ($row instanceof Asset) {
24
            $id = $row->getId();
25 14
        } elseif (is_array($row)) {
26 14
            $id = isset($row[static::ID]) ? $row[static::ID] : null;
27
        }
28 14
        $this->addToIndex(static::ID, $offset, $id);
29 14
    }
30
}
31