CollectorManager::runCollector()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 4
dl 0
loc 11
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\Manager;
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\LocaleTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfer\LocaleTransfer 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 Spryker\Shared\SqlCriteriaBuilder\CriteriaBuilder\CriteriaBuilderInterface;
13
use SprykerEco\Zed\Econda\Business\Collector\DatabaseCollectorInterface;
14
use SprykerEco\Zed\Econda\Business\Exporter\Writer\File\FileWriterInterface;
15
use SprykerEco\Zed\Econda\Business\Helper\ProgressBarHelperInterface;
16
use SprykerEco\Zed\Econda\Persistence\EcondaQueryContainerInterface;
17
use Symfony\Component\Console\Output\OutputInterface;
18
19
class CollectorManager implements CollectorManagerInterface
20
{
21
    /**
22
     * @var \Spryker\Shared\SqlCriteriaBuilder\CriteriaBuilder\CriteriaBuilderInterface
23
     */
24
    protected $criteriaBuilder;
25
26
    /**
27
     * @var \SprykerEco\Zed\Econda\Persistence\EcondaQueryContainerInterface
28
     */
29
    protected $queryContainer;
30
31
    /**
32
     * @var \SprykerEco\Zed\Econda\Business\Helper\ProgressBarHelperInterface
33
     */
34
    protected $progressBarHelper;
35
36
    /**
37
     * @var \SprykerEco\Zed\Econda\Business\Collector\DatabaseCollectorInterface
38
     */
39
    protected $databaseCollector;
40
41
    /**
42
     * @param \Spryker\Shared\SqlCriteriaBuilder\CriteriaBuilder\CriteriaBuilderInterface $criteriaBuilder
43
     * @param \SprykerEco\Zed\Econda\Persistence\EcondaQueryContainerInterface $queryContainer
44
     * @param \SprykerEco\Zed\Econda\Business\Helper\ProgressBarHelperInterface $progressBarHelper
45
     * @param \SprykerEco\Zed\Econda\Business\Collector\DatabaseCollectorInterface $databaseCollector
46
     */
47
    public function __construct(
48
        CriteriaBuilderInterface $criteriaBuilder,
49
        EcondaQueryContainerInterface $queryContainer,
50
        ProgressBarHelperInterface $progressBarHelper,
51
        DatabaseCollectorInterface $databaseCollector
52
    ) {
53
        $this->criteriaBuilder = $criteriaBuilder;
54
        $this->queryContainer = $queryContainer;
55
        $this->progressBarHelper = $progressBarHelper;
56
        $this->databaseCollector = $databaseCollector;
57
    }
58
59
    /**
60
     * @param \Generated\Shared\Transfer\LocaleTransfer $localeTransfer
61
     * @param \Generated\Shared\Transfer\BatchResultTransfer $batchResultTransfer
62
     * @param \SprykerEco\Zed\Econda\Business\Exporter\Writer\File\FileWriterInterface $dataWriter
63
     * @param \Symfony\Component\Console\Output\OutputInterface $output
64
     *
65
     * @return void
66
     */
67
    public function runCollector(
68
        LocaleTransfer $localeTransfer,
69
        BatchResultTransfer $batchResultTransfer,
70
        FileWriterInterface $dataWriter,
71
        OutputInterface $output
72
    ): void {
73
        $batchCollection = $this->databaseCollector
74
            ->createIteratorAndPrepareQuery($localeTransfer, $this->criteriaBuilder, $this->queryContainer);
75
        $progressBar = $this->progressBarHelper->startProgressBar($output, '', $batchCollection->count());
76
        $this->databaseCollector
77
            ->exportDataToStore($batchCollection, $batchResultTransfer, $dataWriter, $localeTransfer, $output, $progressBar);
78
    }
79
}
80