Magic360GalleryUpdateObserver   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 1
dl 0
loc 26
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A initializeMagic360Gallery() 0 15 2
1
<?php
2
3
/**
4
 * TechDivision\Import\Product\Magic360\Observers\Magic360GalleryUpdateObserver
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
 * @author    Bernhard Wick <[email protected]>
16
 * @copyright 2017 TechDivision GmbH <[email protected]>
17
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
18
 * @link      https://github.com/techdivision/import-product-magic360
19
 * @link      http://www.techdivision.com
20
 */
21
22
namespace TechDivision\Import\Product\Magic360\Observers;
23
24
use TechDivision\Import\Product\Magic360\Utils\MemberNames;
25
26
/**
27
 * Observer that creates/updates the magic360 gallery value information.
28
 *
29
 * @author    Tim Wagner <[email protected]>
30
 * @author    Bernhard Wick <[email protected]>
31
 * @copyright 2017 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-magic360
34
 * @link      http://www.techdivision.com
35
 */
36
class Magic360GalleryUpdateObserver extends Magic360GalleryObserver
37
{
38
39
    /**
40
     * Initialize the gallery value with the passed attributes and returns an instance.
41
     *
42
     * @param array $attr The product media gallery value attributes
43
     *
44
     * @return array The initialized product media gallery value
45
     */
46
    protected function initializeMagic360Gallery(array $attr)
47
    {
48
49
        // load product ID and position
50
        $productId = $attr[MemberNames::PRODUCT_ID];
51
        $position = $attr[MemberNames::POSITION];
52
53
        // query whether the product media gallery value already exists or not
54
        if ($entity = $this->getProductMagic360Processor()->loadMagic360Gallery($productId, $position)) {
0 ignored issues
show
Bug introduced by
The method loadMagic360Gallery() does not seem to exist on object<TechDivision\Impo...unchProcessorInterface>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
55
            return $this->mergeEntity($entity, $attr);
56
        }
57
58
        // simply return the attributes
59
        return $attr;
60
    }
61
}
62