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

PriceCollection   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
 * @link https://docs.commercetools.com/http-api-projects-products.html#price
11
 * @method Price current()
12
 * @method PriceCollection add(Price $element)
13
 * @method Price getAt($offset)
14
 * @method Price getById($offset)
15
 */
16
class PriceCollection extends Collection
17
{
18
    protected $type = Price::class;
19
20 36
    protected function indexRow($offset, $row)
21
    {
22 36
        $id = null;
23 36
        if ($row instanceof Price) {
24
            $id = $row->getId();
25 36
        } elseif (is_array($row)) {
26 36
            $id = isset($row[static::ID]) ? $row[static::ID] : null;
27
        }
28 36
        $this->addToIndex(static::ID, $offset, $id);
29 36
    }
30
}
31