Completed
Push — master ( 18bfc7...82e0b5 )
by Jens
18:00 queued 05:19
created

LocalizedEnumCollection   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 75%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 2
dl 0
loc 25
ccs 6
cts 8
cp 0.75
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getByKey() 0 4 1
A indexRow() 0 9 2
1
<?php
2
/**
3
 * @author @jayS-de <[email protected]>
4
 */
5
6
namespace Commercetools\Core\Model\Common;
7
8
/**
9
 * @package Commercetools\Core\Model\Common
10
 * @link https://dev.commercetools.com/http-api-projects-products.html#attribute
11
 * @link https://dev.commercetools.com/http-api-projects-productTypes.html#localizedenumvalue
12
 * @method LocalizedEnum current()
13
 * @method LocalizedEnumCollection add(LocalizedEnum $element)
14
 * @method LocalizedEnum getAt($offset)
15
 */
16
class LocalizedEnumCollection extends Collection
17
{
18
    const KEY = 'key';
19
20
    protected $type = '\Commercetools\Core\Model\Common\LocalizedEnum';
21
22 4
    protected function indexRow($offset, $row)
23
    {
24 4
        if ($row instanceof LocalizedEnum) {
25 2
            $key = $row->getKey();
26
        } else {
27 3
            $key = $row[static::KEY];
28
        }
29 4
        $this->addToIndex(static::KEY, $offset, $key);
30 4
    }
31
32
    /**
33
     * @param $key
34
     * @return static
35
     */
36
    public function getByKey($key)
37
    {
38
        return $this->getBy(static::KEY, $key);
39
    }
40
}
41