RegenerateProductsCacheCommand   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 34
c 0
b 0
f 0
wmc 2
lcom 1
cbo 2
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 11 1
A execute() 0 5 1
1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * File: RegenerateProductsCacheCommand.php
7
 *
8
 * @author Maciej Sławik <[email protected]>
9
 * @copyright Copyright (C) 2019 Lizard Media (http://lizardmedia.pl)
10
 */
11
12
namespace LizardMedia\VarnishWarmer\Console\Command;
13
14
use Symfony\Component\Console\Input\InputInterface;
15
use Symfony\Component\Console\Input\InputOption;
16
use Symfony\Component\Console\Output\OutputInterface;
17
18
/**
19
 * Class RegenerateProductsCacheCommand
20
 * @package LizardMedia\VarnishWarmer\Console\Command
21
 */
22
class RegenerateProductsCacheCommand extends AbstractPurgeCommand
23
{
24
    /**
25
     * @var string
26
     */
27
    public const CLI_COMMAND = 'lm-varnish:regenerate-products-cache';
28
29
    /**
30
     * @return void
31
     */
32
    protected function configure(): void
33
    {
34
        $this->setName(self::CLI_COMMAND)
35
            ->setDescription(
36
                'Get all active, enabled and visible products, clear and regenerate varnish cache by URL'
37
            )->addOption(
38
                self::STORE_VIEW_ID,
39
                null,
40
                InputOption::VALUE_OPTIONAL
41
            );
42
    }
43
44
    /**
45
     * @param InputInterface $input
46
     * @param OutputInterface $output
47
     * @return void
48
     * @SuppressWarnings(PHPMD.UnusedFormalParameter)
49
     */
50
    protected function execute(InputInterface $input, OutputInterface $output): void
51
    {
52
        $this->passStoreViewIfSet($input);
53
        $this->varnishActionManager->purgeAndRegenerateProducts();
54
    }
55
}
56