Completed
Pull Request — master (#478)
by Sven
06:18
created

ImageImportCommand::getImageImport()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 6

Duplication

Lines 12
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 6
nc 1
nop 0
dl 12
loc 12
rs 9.4285
c 1
b 0
f 0
1
<?php
2
/**
3
 * (c) shopware AG <[email protected]>
4
 * For the full copyright and license information, please view the LICENSE
5
 * file that was distributed with this source code.
6
 */
7
8
namespace ShopwarePlugins\Connect\Commands;
9
10
use Shopware\Commands\ShopwareCommand;
11
use Symfony\Component\Console\Input\InputArgument;
12
use Symfony\Component\Console\Input\InputInterface;
13
use Symfony\Component\Console\Output\OutputInterface;
14
use Symfony\Component\Console\Style\SymfonyStyle;
15
use ShopwarePlugins\Connect\Components\ImageImport;
16
use ShopwarePlugins\Connect\Components\Logger;
17
use ShopwarePlugins\Connect\Components\Helper;
18
19
20
class ImageImportCommand extends ShopwareCommand
21
{
22
    /**
23
     * @var Helper
24
     */
25
    private $helper;
26
27
    public function __construct(Helper $helper) {
28
        parent::__construct();
29
        $this->helper = $helper;
30
    }
31
32
    protected function configure()
33
    {
34
        $this
35
            ->setName('connect:image:import')
36
            ->setDescription('Import images from connect')
37
            ->addArgument(
38
                'limit',
39
                InputArgument::OPTIONAL,
40
                'Amount of Images to import at once'
41
            );
42
    }
43
44
    /**
45
     * @param InputInterface $input
46
     * @param OutputInterface $output
47
     */
48
    protected function execute(InputInterface $input, OutputInterface $output)
49
    {
50
        $symfonyStyle = new SymfonyStyle($input, $output);
51
        $limit = $input->getArgument('limit') | 10;
52
53
        $this->getImageImport()->import($limit);
54
55
        $symfonyStyle->success('Images were imported.');
56
    }
57
58
    /**
59
     * @return ImageImport
60
     */
61 View Code Duplication
    private function getImageImport()
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...
62
    {
63
        // do not use thumbnail_manager as a dependency!!!
0 ignored issues
show
Unused Code Comprehensibility introduced by
36% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
64
        // MediaService::__construct uses Shop entity
65
        // this also could break the session in backend when it's used in subscriber
66
        return new ImageImport(
67
            Shopware()->Models(),
68
            $this->helper,
69
            $this->container->get('thumbnail_manager'),
70
            new Logger(Shopware()->Db())
71
        );
72
    }
73
}
74