Completed
Push — master ( 30006e...81f604 )
by Tim
9s
created

EeProductAttributeUpdateObserver::loadDecimalAttribute()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
cc 1
eloc 2
nc 1
nop 3
crap 2
1
<?php
2
3
/**
4
 * TechDivision\Import\Product\Ee\Observers\EeProductAttributeUpdateObserver
5
 *
6
 * NOTICE OF LICENSE
7
 *
8
 * This source file is subject to the Open Software License (OSL 3.0)
9
 * that is available through the world-wide-web at this URL:
10
 * http://opensource.org/licenses/osl-3.0.php
11
 *
12
 * PHP version 5
13
 *
14
 * @author    Tim Wagner <[email protected]>
15
 * @copyright 2016 TechDivision GmbH <[email protected]>
16
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
 * @link      https://github.com/techdivision/import-product-ee
18
 * @link      http://www.techdivision.com
19
 */
20
21
namespace TechDivision\Import\Product\Ee\Observers;
22
23
use TechDivision\Import\Product\Ee\Utils\MemberNames;
24
use TechDivision\Import\Ee\Observers\EeAttributeObserverTrait;
25
use TechDivision\Import\Product\Observers\ProductAttributeUpdateObserver;
26
27
/**
28
 * Observer that provides product attribute update functionality.
29
 *
30
 * @author    Tim Wagner <[email protected]>
31
 * @copyright 2016 TechDivision GmbH <[email protected]>
32
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
33
 * @link      https://github.com/techdivision/import-product-ee
34
 * @link      http://www.techdivision.com
35
 */
36
class EeProductAttributeUpdateObserver extends ProductAttributeUpdateObserver
37
{
38
39
    /**
40
     * The trait providing basic EE product attribute functionality.
41
     *
42
     * @var \TechDivision\Import\Ee\Observers\EeAttributeObserverTrait
43
     */
44
    use EeAttributeObserverTrait;
45
46
    /**
47
     * Initialize the category product with the passed attributes and returns an instance.
48
     *
49
     * @param array $attr The category product attributes
50
     *
51
     * @return array The initialized category product
52
     */
53
    protected function initializeAttribute(array $attr)
54
    {
55
56
        // try to load the attribute with the passed attribute ID and merge it with the attributes
57
        if (isset($this->attributes[$attributeId = (integer) $attr[MemberNames::ATTRIBUTE_ID]])) {
58
            return $this->mergeEntity($this->attributes[$attributeId], $attr);
59
        }
60
61
        // otherwise simply return the attributes
62
        return $attr;
63
    }
64
}
65