Completed
Push — develop ( c6f9f9...59e20d )
by Jens
09:32
created

ProductProjectionCollection::getById()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
/**
3
 * @author @jayS-de <[email protected]>
4
 */
5
6
namespace Commercetools\Core\Model\Product;
7
8
use Commercetools\Core\Model\Common\Collection;
9
10
/**
11
 * @package Commercetools\Core\Model\Product
12
 * @link https://dev.commercetools.com/http-api-projects-products.html#product-projection
13
 * @method ProductProjection current()
14
 * @method ProductProjectionCollection add(ProductProjection $element)
15
 * @method ProductProjection getAt($offset)
16
 */
17 View Code Duplication
class ProductProjectionCollection 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\Product\ProductProjection';
20
21 6
    protected function indexRow($offset, $row)
22
    {
23 6
        if ($row instanceof ProductProjection) {
24 1
            $id = $row->getId();
25
        } else {
26 5
            $id = $row[static::ID];
27
        }
28 6
        $this->addToIndex(static::ID, $offset, $id);
29 6
    }
30
}
31