Completed
Push — develop ( b37c60...7b776f )
by
unknown
42:54 queued 11:25
created

AddressCollection::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

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
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\Common;
7
8
/**
9
 * @package Commercetools\Core\Model\Common
10
 * @method Address current()
11
 * @method AddressCollection add(Address $element)
12
 * @method Address getAt($offset)
13
 */
14
class AddressCollection extends Collection
15
{
16
    const ID = 'id';
17
18
    protected $type = '\Commercetools\Core\Model\Common\Address';
19
20 2
    protected function indexRow($offset, $row)
21
    {
22 2
        if ($row instanceof Address) {
23
            $name = $row->getId();
24
        } else {
25 2
            $name = $row[static::ID];
26
        }
27 2
        $this->addToIndex(static::ID, $offset, $name);
28 2
    }
29
30
    /**
31
     * @param $id
32
     * @return Address|null
33
     */
34 2
    public function getById($id)
35
    {
36 2
        return $this->getBy(static::ID, $id);
37
    }
38
}
39