ProductExporterPlugin::run()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 17
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 10
nc 2
nop 4
dl 0
loc 17
rs 9.9332
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\Communication\Plugin;
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\Zed\Kernel\Communication\AbstractPlugin;
13
use SprykerEco\Zed\Econda\Business\Exporter\Writer\File\FileWriterInterface;
14
use SprykerEco\Zed\Econda\Dependency\Plugin\ExporterPluginInterface;
15
use Symfony\Component\Console\Output\OutputInterface;
16
17
/**
18
 * @method \SprykerEco\Zed\Econda\Business\EcondaFacadeInterface getFacade()
19
 * @method \SprykerEco\Zed\Econda\EcondaConfig getConfig()
20
 * @method \SprykerEco\Zed\Econda\Persistence\EcondaQueryContainerInterface getQueryContainer()
21
 */
22
class ProductExporterPlugin extends AbstractPlugin implements ExporterPluginInterface
23
{
24
    /**
25
     * {@inheritDoc}
26
     *
27
     * @api
28
     *
29
     * @param \Generated\Shared\Transfer\LocaleTransfer $localeTransfer
30
     * @param \Generated\Shared\Transfer\BatchResultTransfer $batchResultTransfer
31
     * @param \SprykerEco\Zed\Econda\Business\Exporter\Writer\File\FileWriterInterface $dataWriter
32
     * @param \Symfony\Component\Console\Output\OutputInterface $output
33
     *
34
     * @return void
35
     */
36
    public function run(
37
        LocaleTransfer $localeTransfer,
38
        BatchResultTransfer $batchResultTransfer,
39
        FileWriterInterface $dataWriter,
40
        OutputInterface $output
41
    ): void {
42
        $csvDir = $this->getConfig()->getFileExportPath();
43
        if (!is_dir($csvDir)) {
44
            mkdir($csvDir);
45
        }
46
        $dataWriter->setFolderPath($csvDir);
47
        $this->getFacade()
48
            ->exportProducts(
49
                $localeTransfer,
50
                $batchResultTransfer,
51
                $dataWriter,
52
                $output
53
            );
54
    }
55
}
56