IndexExportCommand::configure()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 25

Duplication

Lines 25
Ratio 100 %

Importance

Changes 0
Metric Value
dl 25
loc 25
rs 9.52
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of the ONGR package.
5
 *
6
 * (c) NFQ Technologies UAB <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace ONGR\ElasticsearchBundle\Command;
13
14
use ONGR\ElasticsearchBundle\Service\ExportService;
15
use Symfony\Component\Console\Input\InputArgument;
16
use Symfony\Component\Console\Input\InputInterface;
17
use Symfony\Component\Console\Input\InputOption;
18
use Symfony\Component\Console\Output\OutputInterface;
19
use Symfony\Component\Console\Style\SymfonyStyle;
20
21
class IndexExportCommand extends AbstractIndexServiceAwareCommand
22
{
23
    const NAME = 'ongr:es:index:export';
24
25
    /**
26
     * {@inheritdoc}
27
     */
28 View Code Duplication
    protected function configure()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
29
    {
30
        parent::configure();
31
32
        $this
33
            ->setName(self::NAME)
34
            ->setDescription('Exports a data from the ElasticSearch index.')
35
            ->addArgument(
36
                'filename',
37
                InputArgument::REQUIRED,
38
                'Define a filename to store the output'
39
            )->addOption(
40
                'chunk',
41
                null,
42
                InputOption::VALUE_REQUIRED,
43
                'Chunk size to use in the scan api',
44
                500
45
            )->addOption(
46
                'split',
47
                null,
48
                InputOption::VALUE_REQUIRED,
49
                'Split a file content in a separate parts if a line number exceeds provided value',
50
                300000
51
            );
52
    }
53
54
    /**
55
     * {@inheritdoc}
56
     */
57 View Code Duplication
    protected function execute(InputInterface $input, OutputInterface $output)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
58
    {
59
        $io = new SymfonyStyle($input, $output);
60
        $index = $this->getIndex($input->getOption(parent::INDEX_OPTION));
61
62
        /** @var ExportService $exportService */
63
        $exportService = $this->getContainer()->get(ExportService::class);
64
        $exportService->exportIndex(
65
            $index,
66
            $input->getArgument('filename'),
67
            $input->getOption('chunk'),
68
            $output,
69
            $input->getOption('split')
70
        );
71
72
        $io->success('Data export completed!');
73
74
        return 0;
75
    }
76
}
77