CustomerAddressAttributeUpdateObserver   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 4
c 1
b 0
f 0
dl 0
loc 20
ccs 0
cts 4
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A initializeAttribute() 0 10 2
1
<?php
2
3
/**
4
 * TechDivision\Import\Customer\Address\Observers\CustomerAddressAttributeUpdateObserver
5
 *
6
 * PHP version 7
7
 *
8
 * @author    Tim Wagner <[email protected]>
9
 * @copyright 2018 TechDivision GmbH <[email protected]>
10
 * @license   https://opensource.org/licenses/MIT
11
 * @link      https://github.com/techdivision/import-customer-address
12
 * @link      http://www.techdivision.com
13
 */
14
15
namespace TechDivision\Import\Customer\Address\Observers;
16
17
use TechDivision\Import\Customer\Address\Utils\MemberNames;
18
19
/**
20
 * Observer that creates/updates the customer address's attributes.
21
 *
22
 * @author    Tim Wagner <[email protected]>
23
 * @copyright 2018 TechDivision GmbH <[email protected]>
24
 * @license   https://opensource.org/licenses/MIT
25
 * @link      https://github.com/techdivision/import-customer-address
26
 * @link      http://www.techdivision.com
27
 */
28
class CustomerAddressAttributeUpdateObserver extends CustomerAddressAttributeObserver
29
{
30
31
    /**
32
     * Initialize the customer address with the passed attributes and returns an instance.
33
     *
34
     * @param array $attr The category customer attributes
35
     *
36
     * @return array The initialized category customer
37
     */
38
    protected function initializeAttribute(array $attr)
39
    {
40
41
        // try to load the attribute with the passed attribute ID and merge it with the attributes
42
        if (isset($this->attributes[$attributeId = (integer) $attr[MemberNames::ATTRIBUTE_ID]])) {
43
            return $this->mergeEntity($this->attributes[$attributeId], $attr);
44
        }
45
46
        // otherwise simply return the attributes
47
        return $attr;
48
    }
49
}
50