Completed
Push — development ( b7d203...b8b391 )
by Ivan
09:43
created

createDefaultBatchResultTransfer()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 7
rs 10
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\File\FileWriterInterface;
13
14
abstract class AbstractExporter implements ExporterInterface
15
{
16
    /**
17
     * @var \SprykerEco\Zed\Econda\Dependency\Plugin\EcondaPluginInterface[]
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
     * @var \Spryker\Zed\Touch\Persistence\TouchQueryContainerInterface
38
     */
39
    protected $queryContainer;
40
41
    /**
42
     * @param \SprykerEco\Zed\Econda\Business\Exporter\Writer\File\FileWriterInterface $writer
43
     * @param array $collectorPlugins
44
     */
45
    public function __construct(
46
        FileWriterInterface $writer,
47
        array $collectorPlugins = []
48
    ) {
49
        $this->writer = $writer;
50
        $this->collectorPlugins = $collectorPlugins;
51
        $this->failedResultTransfer = new FailedResultTransfer();
52
        $this->batchResultTransfer = new BatchResultTransfer();
53
    }
54
55
    /**
56
     * @return \SprykerEco\Zed\Econda\Dependency\Plugin\EcondaPluginInterface[]
57
     */
58
    public function getCollectorPlugins(): EcondaPluginInterface
0 ignored issues
show
Bug introduced by
The type SprykerEco\Zed\Econda\Bu...r\EcondaPluginInterface 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...
59
    {
60
        return $this->collectorPlugins;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->collectorPlugins returns the type SprykerEco\Zed\Econda\De...EcondaPluginInterface[] which is incompatible with the type-hinted return SprykerEco\Zed\Econda\Bu...r\EcondaPluginInterface.
Loading history...
61
    }
62
63
    /**
64
     * @param string $type
65
     *
66
     * @return bool
67
     */
68
    protected function isCollectorRegistered($type): bool
69
    {
70
        return array_key_exists($type, $this->collectorPlugins);
71
    }
72
73
    /**
74
     * @param \Generated\Shared\Transfer\BatchResultTransfer $result
75
     *
76
     * @return void
77
     */
78
    protected function resetResult(BatchResultTransfer $result): void
79
    {
80
        $result->setProcessedCount(0);
81
        $result->setIsFailed(false);
82
        $result->setTotalCount(0);
83
        $result->setDeletedCount(0);
84
    }
85
86
    /**
87
     * @return \Generated\Shared\Transfer\BatchResultTransfer
88
     */
89
    protected function createDefaultBatchResultTransfer(): BatchResultTransfer
90
    {
91
        $resultBatchTransfer = clone $this->batchResultTransfer;
92
        $resultBatchTransfer->setDeletedCount(0);
93
        $resultBatchTransfer->setFailedCount(0);
94
95
        return $resultBatchTransfer;
96
    }
97
}
98