storeViewHasBeenProcessed()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
ccs 0
cts 2
cp 0
rs 10
cc 1
nc 1
nop 2
crap 2
1
<?php
2
3
/**
4
 * TechDivision\Import\Customer\Address\Observers\AbstractCustomerAddressImportObserver
5
 *
6
 * PHP version 7
7
 *
8
 * @author    Tim Wagner <[email protected]>
9
 * @copyright 2018 TechDivision GmbH <[email protected]>
10
 * @license   https://opensource.org/licenses/MIT
11
 * @link      https://github.com/techdivision/import-customer-address
12
 * @link      http://www.techdivision.com
13
 */
14
15
namespace TechDivision\Import\Customer\Address\Observers;
16
17
use TechDivision\Import\Customer\Address\Utils\ColumnKeys;
18
use TechDivision\Import\Subjects\SubjectInterface;
19
use TechDivision\Import\Observers\AbstractObserver;
20
21
/**
22
 * Abstract category observer that handles the process to import customer address bunches.
23
 *
24
 * @author    Tim Wagner <[email protected]>
25
 * @copyright 2018 TechDivision GmbH <[email protected]>
26
 * @license   https://opensource.org/licenses/MIT
27
 * @link      https://github.com/techdivision/import-customer-address
28
 * @link      http://www.techdivision.com
29
 */
30
abstract class AbstractCustomerAddressImportObserver extends AbstractObserver implements CustomerAddressImportObserverInterface
31
{
32
33
    /**
34
     * Will be invoked by the action on the events the listener has been registered for.
35
     *
36
     * @param \TechDivision\Import\Subjects\SubjectInterface $subject The subject instance
37
     *
38
     * @return array The modified row
39
     * @see \TechDivision\Import\Observers\ObserverInterface::handle()
40
     */
41
    public function handle(SubjectInterface $subject)
42
    {
43
44
        // initialize the row
45
        $this->setSubject($subject);
46
        $this->setRow($subject->getRow());
47
48
        // process the functionality and return the row
49
        $this->process();
50
51
        // return the processed row
52
        return $this->getRow();
53
    }
54
55
    /**
56
     * Process the observer's business logic.
57
     *
58
     * @return void
59
     */
60
    abstract protected function process();
61
62
    /**
63
     * Return's the column names that contains the primary key.
64
     *
65
     * @return array the column names that contains the primary key
66
     */
67
    protected function getPrimaryKeyColumnName()
68
    {
69
        return array(ColumnKeys::EMAIL, ColumnKeys::WEBSITE);
70
    }
71
72
    /**
73
     * Queries whether or not the passed customer identifier and store view code has already been processed.
74
     *
75
     * @param array  $identifier    The customer identifier to check been processed
76
     * @param string $storeViewCode The store view code to check been processed
77
     *
78
     * @return boolean TRUE if the customer with the passed identifier and store view code has been processed, else FALSE
79
     */
80
    protected function storeViewHasBeenProcessed(array $identifier, $storeViewCode)
81
    {
82
        return $this->getSubject()->storeViewHasBeenProcessed($identifier, $storeViewCode);
83
    }
84
85
    /**
86
     * Return's TRUE if the passed entity ID is the actual one.
87
     *
88
     * @param integer $entityId The customer address entity ID to check
89
     *
90
     * @return boolean TRUE if the passed customer address entity ID is the actual one
91
     */
92
    protected function isLastEntityId($entityId)
93
    {
94
        return $this->getSubject()->getLastEntityId() === $entityId;
95
    }
96
}
97