Passed
Push — development ( 1d0c17...26e4cc )
by Theodoros
03:20
created

AbstractExporter::getBatchResultTransfer()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 0
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * MIT License
5
 * Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file.
6
 */
7
8
namespace SprykerEco\Zed\Econda\Business\Exporter;
9
10
use Generated\Shared\Transfer\BatchResultTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfer\BatchResultTransfer was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
11
use Generated\Shared\Transfer\FailedResultTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfer\FailedResultTransfer was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
12
use SprykerEco\Zed\Econda\Business\Exporter\Writer\WriterInterface;
13
14
abstract class AbstractExporter implements ExporterInterface
15
{
16
17
    /**
18
     * @var \SprykerEco\Zed\Econda\Dependency\Plugin\EcondaPluginInterface[]
19
     */
20
    protected $collectorPlugins = [];
21
22
    /**
23
     * @var \Generated\Shared\Transfer\FailedResultTransfer
24
     */
25
    protected $failedResultPrototype;
26
27
    /**
28
     * @var \Generated\Shared\Transfer\BatchResultTransfer
29
     */
30
    protected $batchResultTransferPrototype;
31
32
    /**
33
     * @var \SprykerEco\Zed\Econda\Business\Exporter\Writer\WriterInterface
34
     */
35
    protected $writer;
36
37
    /**
38
     * @var \Spryker\Zed\Touch\Persistence\TouchQueryContainerInterface
39
     */
40
    protected $queryContainer;
41
42
    /**
43
     * AbstractExporter constructor.
44
     *
45
     * @param \SprykerEco\Zed\Econda\Business\Exporter\Writer\WriterInterface $writer
46
     * @param \Generated\Shared\Transfer\FailedResultTransfer $failedResultPrototype
47
     * @param \Generated\Shared\Transfer\BatchResultTransfer $batchResultTransferPrototype
48
     * @param array $collectorPlugins
49
     */
50
    public function __construct(
51
        WriterInterface $writer,
52
        FailedResultTransfer $failedResultPrototype,
53
        BatchResultTransfer $batchResultTransferPrototype,
54
        array $collectorPlugins = []
55
    ) {
56
        $this->writer = $writer;
57
        $this->failedResultPrototype = $failedResultPrototype;
58
        $this->batchResultTransferPrototype = $batchResultTransferPrototype;
59
        $this->collectorPlugins = $collectorPlugins;
60
    }
61
62
    /**
63
     * @return \SprykerEco\Zed\Econda\Dependency\Plugin\EcondaPluginInterface[]
64
     */
65
    public function getCollectorPlugins()
66
    {
67
        return $this->collectorPlugins;
68
    }
69
70
    /**
71
     * @param string $type
72
     *
73
     * @return bool
74
     */
75
    protected function isCollectorRegistered($type)
76
    {
77
        return array_key_exists($type, $this->collectorPlugins);
78
    }
79
80
    /**
81
     * @param \Generated\Shared\Transfer\BatchResultTransfer $result
82
     *
83
     * @return void
84
     */
85
    protected function resetResult(BatchResultTransfer $result)
86
    {
87
        $result->setProcessedCount(0);
88
        $result->setIsFailed(false);
89
        $result->setTotalCount(0);
90
        $result->setDeletedCount(0);
91
    }
92
93
    /**
94
     * @return \Generated\Shared\Transfer\BatchResultTransfer
95
     */
96
    protected function getBatchResultTransfer()
97
    {
98
        $resultBatchTransfer = clone $this->batchResultTransferPrototype;
99
        $resultBatchTransfer->setDeletedCount(0);
100
        $resultBatchTransfer->setFailedCount(0);
101
102
        return $resultBatchTransfer;
103
    }
104
105
}
106