Completed
Push — master ( 4b89b9...dd9abc )
by Jens
10:35
created

LocalizedEnumCollection   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 62.5%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 0
cbo 2
dl 0
loc 25
ccs 5
cts 8
cp 0.625
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A indexRow() 0 9 2
A getByKey() 0 4 1
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#product-variant-attribute
11
 * @link https://dev.commercetools.com/http-api-projects-productTypes.html#localized-enum-value
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 2
    protected function indexRow($offset, $row)
23
    {
24 2
        if ($row instanceof Enum) {
25
            $key = $row->getKey();
26
        } else {
27 2
            $key = $row[static::KEY];
28
        }
29 2
        $this->addToIndex(static::KEY, $offset, $key);
30 2
    }
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