Completed
Pull Request — master (#67)
by Tim
08:20
created

ProductAttributeObserver::persistIntAttribute()   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
dl 0
loc 4
ccs 0
cts 0
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 2
1
<?php
2
3
/**
4
 * TechDivision\Import\Product\Observers\ProductAttributeObserver
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
18
 * @link      http://www.techdivision.com
19
 */
20
21
namespace TechDivision\Import\Product\Observers;
22
23
use TechDivision\Import\Observers\AbstractAttributeObserver;
24
use TechDivision\Import\Product\Services\ProductBunchProcessorInterface;
25
26
/**
27
 * Observer that creates/updates the product's attributes.
28
 *
29
 * @author    Tim Wagner <[email protected]>
30
 * @copyright 2016 TechDivision GmbH <[email protected]>
31
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
32
 * @link      https://github.com/techdivision/import-product
33
 * @link      http://www.techdivision.com
34
 */
35
class ProductAttributeObserver extends AbstractAttributeObserver
36
{
37
38
    /**
39
     * The product bunch processor instance.
40
     *
41
     * @var \TechDivision\Import\Product\Services\ProductBunchProcessorInterface
42
     */
43
    protected $productBunchProcessor;
44
45
    /**
46
     * Initialize the observer with the passed product bunch processor instance.
47
     *
48
     * @param \TechDivision\Import\Product\Services\ProductBunchProcessorInterface $productBunchProcessor The product bunch processor instance
49
     */
50
    public function __construct(ProductBunchProcessorInterface $productBunchProcessor)
51
    {
52
        $this->productBunchProcessor = $productBunchProcessor;
53
    }
54
55
    /**
56
     * Return's the product bunch processor instance.
57
     *
58
     * @return \TechDivision\Import\Services\ProductBunchProcessorInterface The product bunch processor instance
59
     */
60
    protected function getProductBunchProcessor()
61
    {
62
        return $this->productBunchProcessor;
63
    }
64
65
    /**
66
     * Persist's the passed varchar attribute.
67
     *
68
     * @param array $attribute The attribute to persist
69
     *
70
     * @return void
71
     */
72
    protected function persistVarcharAttribute($attribute)
73
    {
74
        $this->getProductBunchProcessor()->persistProductVarcharAttribute($attribute);
75
    }
76
77
    /**
78
     * Persist's the passed integer attribute.
79
     *
80
     * @param array $attribute The attribute to persist
81
     *
82
     * @return void
83
     */
84
    protected function persistIntAttribute($attribute)
85
    {
86
        $this->getProductBunchProcessor()->persistProductIntAttribute($attribute);
87
    }
88
89
    /**
90
     * Persist's the passed decimal attribute.
91
     *
92
     * @param array $attribute The attribute to persist
93
     *
94
     * @return void
95
     */
96
    protected function persistDecimalAttribute($attribute)
97
    {
98
        $this->getProductBunchProcessor()->persistProductDecimalAttribute($attribute);
99
    }
100
101
    /**
102
     * Persist's the passed datetime attribute.
103
     *
104
     * @param array $attribute The attribute to persist
105
     *
106
     * @return void
107
     */
108
    protected function persistDatetimeAttribute($attribute)
109
    {
110
        $this->getProductBunchProcessor()->persistProductDatetimeAttribute($attribute);
111
    }
112
113
    /**
114
     * Persist's the passed text attribute.
115
     *
116
     * @param array $attribute The attribute to persist
117
     *
118
     * @return void
119
     */
120
    protected function persistTextAttribute($attribute)
121
    {
122
        $this->getProductBunchProcessor()->persistProductTextAttribute($attribute);
123
    }
124
}
125