AbstractExporter   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 77
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 19
c 1
b 0
f 0
dl 0
loc 77
rs 10
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A createDefaultBatchResultTransfer() 0 7 1
A isCollectorRegistered() 0 3 1
A getCollectorPlugins() 0 3 1
A resetResult() 0 6 1
A __construct() 0 8 1
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\File\FileWriterInterface;
13
14
abstract class AbstractExporter implements ExporterInterface
15
{
16
    /**
17
     * @var \SprykerEco\Zed\Econda\Dependency\Plugin\ExporterPluginInterface[]
18
     */
19
    protected $collectorPlugins = [];
20
21
    /**
22
     * @var \Generated\Shared\Transfer\FailedResultTransfer
23
     */
24
    protected $failedResultTransfer;
25
26
    /**
27
     * @var \Generated\Shared\Transfer\BatchResultTransfer
28
     */
29
    protected $batchResultTransfer;
30
31
    /**
32
     * @var \SprykerEco\Zed\Econda\Business\Exporter\Writer\File\FileWriterInterface
33
     */
34
    protected $writer;
35
36
    /**
37
     * @param \SprykerEco\Zed\Econda\Business\Exporter\Writer\File\FileWriterInterface $writer
38
     * @param array $collectorPlugins
39
     */
40
    public function __construct(
41
        FileWriterInterface $writer,
42
        array $collectorPlugins = []
43
    ) {
44
        $this->writer = $writer;
45
        $this->collectorPlugins = $collectorPlugins;
46
        $this->failedResultTransfer = new FailedResultTransfer();
47
        $this->batchResultTransfer = new BatchResultTransfer();
48
    }
49
50
    /**
51
     * @return \SprykerEco\Zed\Econda\Dependency\Plugin\ExporterPluginInterface[]
52
     */
53
    public function getCollectorPlugins(): array
54
    {
55
        return $this->collectorPlugins;
56
    }
57
58
    /**
59
     * @param string $type
60
     *
61
     * @return bool
62
     */
63
    protected function isCollectorRegistered($type): bool
64
    {
65
        return array_key_exists($type, $this->collectorPlugins);
66
    }
67
68
    /**
69
     * @param \Generated\Shared\Transfer\BatchResultTransfer $result
70
     *
71
     * @return void
72
     */
73
    protected function resetResult(BatchResultTransfer $result): void
74
    {
75
        $result->setProcessedCount(0);
76
        $result->setIsFailed(false);
77
        $result->setTotalCount(0);
78
        $result->setDeletedCount(0);
79
    }
80
81
    /**
82
     * @return \Generated\Shared\Transfer\BatchResultTransfer
83
     */
84
    protected function createDefaultBatchResultTransfer(): BatchResultTransfer
85
    {
86
        $resultBatchTransfer = clone $this->batchResultTransfer;
87
        $resultBatchTransfer->setDeletedCount(0);
88
        $resultBatchTransfer->setFailedCount(0);
89
90
        return $resultBatchTransfer;
91
    }
92
}
93