Completed
Pull Request — master (#40)
by Tim
05:10
created

persistDatetimeAttribute()

Size

Total Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 1
ccs 0
cts 0
cp 0
c 0
b 0
f 0
nc 1
1
<?php
2
3
/**
4
 * TechDivision\Import\Observers\AbstractAttributeObserver
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
18
 * @link      http://www.techdivision.com
19
 */
20
21
namespace TechDivision\Import\Observers;
22
23
/**
24
 * Observer that creates/updates the EAV attributes.
25
 *
26
 * @author    Tim Wagner <[email protected]>
27
 * @copyright 2016 TechDivision GmbH <[email protected]>
28
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
29
 * @link      https://github.com/techdivision/import
30
 * @link      http://www.techdivision.com
31
 */
32
abstract class AbstractAttributeObserver extends AbstractObserver
33
{
34
35
    /**
36
     * The trait that provides the functionality to persist the attributes found in the CSV file.
37
     *
38
     * @var \TechDivision\Import\Observers\AttributeObserverTrait
39
     */
40
    use AttributeObserverTrait;
41
42
    /**
43
     * Will be invoked by the action on the events the listener has been registered for.
44
     *
45
     * @param array $row The row to handle
46
     *
47
     * @return array The modified row
48
     * @see \TechDivision\Import\Observers\ObserverInterface::handle()
49
     */
50
    public function handle(array $row)
51
    {
52
53
        // initialize the row
54
        $this->setRow($row);
55
56
        // process the functionality and return the row
57
        $this->process();
58
59
        // return the processed row
60
        return $this->getRow();
61
    }
62
63
    /**
64
     * Persist's the passed varchar attribute.
65
     *
66
     * @param array $attribute The attribute to persist
67
     *
68
     * @return void
69
     */
70
    abstract protected function persistVarcharAttribute($attribute);
71
72
    /**
73
     * Persist's the passed integer attribute.
74
     *
75
     * @param array $attribute The attribute to persist
76
     *
77
     * @return void
78
     */
79
    abstract protected function persistIntAttribute($attribute);
80
81
    /**
82
     * Persist's the passed decimal attribute.
83
     *
84
     * @param array $attribute The attribute to persist
85
     *
86
     * @return void
87
     */
88
    abstract protected function persistDecimalAttribute($attribute);
89
90
    /**
91
     * Persist's the passed datetime attribute.
92
     *
93
     * @param array $attribute The attribute to persist
94
     *
95
     * @return void
96
     */
97
    abstract protected function persistDatetimeAttribute($attribute);
98
99
    /**
100
     * Persist's the passed text attribute.
101
     *
102
     * @param array $attribute The attribute to persist
103
     *
104
     * @return void
105
     */
106
    abstract protected function persistTextAttribute($attribute);
107
}
108