Completed
Push — master ( 4e986c...7c30c4 )
by Tim
19s queued 12s
created

isLastEntityId()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

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