DeltaProductWriter   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 4
c 2
b 0
f 0
lcom 1
cbo 4
dl 0
loc 58
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 1
A write() 0 10 2
A setStepExecution() 0 7 1
1
<?php
2
3
namespace Actualys\Bundle\DrupalCommerceConnectorBundle\Writer;
4
5
use Akeneo\Bundle\BatchBundle\Entity\JobInstance;
6
use Pim\Bundle\CatalogBundle\Manager\ChannelManager;
7
use Pim\Bundle\DeltaExportBundle\Manager\ProductExportManager;
8
use Akeneo\Bundle\BatchBundle\Entity\StepExecution;
9
use Symfony\Component\EventDispatcher\EventDispatcher;
10
use Guzzle\Http\Exception\ClientErrorResponseException;
11
12
class DeltaProductWriter extends ProductWriter
13
{
14
    /**
15
     * @var ProductExportManager
16
     */
17
    protected $productExportManager;
18
19
    /**
20
     * @var JobInstance
21
     */
22
    protected $jobInstance;
23
24
    /**
25
     * @var EventDispatcher
26
     */
27
    protected $eventDispatcher;
28
29
    /**
30
     * Constructor
31
     *
32
     * @param EventDispatcher      $eventDispatcher
33
     * @param ChannelManager       $channelManager
34
     * @param ProductExportManager $productExportManager
35
     */
36
    public function __construct(
37
      EventDispatcher $eventDispatcher,
38
      ChannelManager $channelManager,
0 ignored issues
show
Unused Code introduced by
The parameter $channelManager is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
39
      ProductExportManager $productExportManager
40
    ) {
41
        $this->eventDispatcher = $eventDispatcher;
42
        $this->productExportManager = $productExportManager;
43
    }
44
45
    /**
46
     * @param array $items
47
     */
48
    public function write(array $items)
49
    {
50
        parent::write($items);
51
        foreach ($items as $item) {
52
            $this->productExportManager->updateProductExport(
53
              $item['sku'],
54
              $this->jobInstance
55
            );
56
        }
57
    }
58
59
    /**
60
     * {@inheritdoc}
61
     */
62
    public function setStepExecution(StepExecution $stepExecution)
63
    {
64
        parent::setStepExecution($stepExecution);
65
66
        $this->jobInstance = $stepExecution->getJobExecution()->getJobInstance(
67
        );
68
    }
69
}
70