Completed
Pull Request — master (#201)
by
unknown
02:03
created

AbstractAttributeObserver::handle()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

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