AbstractProductTierPriceObserver   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 6
c 1
b 0
f 0
dl 0
loc 51
ccs 0
cts 8
cp 0
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getPrimaryKeyMemberName() 0 3 1
A getTierPriceProcessor() 0 3 1
A setLastPk() 0 3 1
A __construct() 0 3 1
1
<?php
2
3
/**
4
 * TechDivision\Import\Product\TierPrice\Observers\AbstractProductTierPriceObserver
5
 *
6
 * PHP version 7
7
 *
8
 * @author    Tim Wagner <[email protected]>
9
 * @license   https://opensource.org/licenses/MIT
10
 * @link      https://github.com/techdivision/import-product-tier-price
11
 * @link      https://www.techdivision.com
12
 */
13
14
namespace TechDivision\Import\Product\TierPrice\Observers;
15
16
use TechDivision\Import\Product\Observers\AbstractProductImportObserver;
17
use TechDivision\Import\Product\TierPrice\Services\TierPriceProcessorInterface;
18
19
/**
20
 * Observer for deleting tier prices from the database.
21
 *
22
 * @author    Tim Wagner <[email protected]>
23
 * @license   https://opensource.org/licenses/MIT
24
 * @link      https://github.com/techdivision/import-product-tier-price
25
 * @link      https://www.techdivision.com
26
 */
27
abstract class AbstractProductTierPriceObserver extends AbstractProductImportObserver
28
{
29
30
    /**
31
     * The product tier price processor instance.
32
     *
33
     * @var \TechDivision\Import\Product\TierPrice\Services\TierPriceProcessorInterface
34
     */
35
    protected $tierPriceProcessor;
36
37
    /**
38
     * Initialize the observer with the passed product tier price processor instance.
39
     *
40
     * @param \TechDivision\Import\Product\TierPrice\Services\TierPriceProcessorInterface $tierPriceProcessor The processor instance
41
     */
42
    public function __construct(TierPriceProcessorInterface $tierPriceProcessor)
43
    {
44
        $this->tierPriceProcessor = $tierPriceProcessor;
45
    }
46
47
    /**
48
     * Returns the product tier price rewrite processor instance.
49
     *
50
     * @return \TechDivision\Import\Product\TierPrice\Services\TierPriceProcessorInterface The processor instance
51
     */
52
    protected function getTierPriceProcessor()
53
    {
54
        return $this->tierPriceProcessor;
55
    }
56
57
    /**
58
     * Returns the primary key member name for the actual Magento edition.
59
     *
60
     * @return string The primary key member name
61
     * @see \TechDivision\Import\Product\TierPrice\Services\TierPriceProcessorInterface::getPrimaryKeyMemberName()
62
     */
63
    protected function getPrimaryKeyMemberName()
64
    {
65
        return $this->getTierPriceProcessor()->getPrimaryKeyMemberName();
66
    }
67
68
    /**
69
     * Set's the ID of the last PK used.
70
     *
71
     * @param string $pk The PK
72
     *
73
     * @return void
74
     */
75
    protected function setLastPk($pk)
76
    {
77
        $this->getSubject()->setLastPk($pk);
78
    }
79
}
80