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

AssetCollection   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Test Coverage

Coverage 85.71%

Importance

Changes 0
Metric Value
wmc 4
dl 0
loc 13
ccs 6
cts 7
cp 0.8571
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\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