Completed
Push — master ( 280340...8fd247 )
by Sean
11s
created

PurgeSiteCommand::initialize()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 2
dl 0
loc 6
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Incapsula\Command;
4
5
use Symfony\Component\Console\Input\InputArgument;
6
use Symfony\Component\Console\Input\InputInterface;
7
use Symfony\Component\Console\Output\OutputInterface;
8
9
class PurgeSiteCommand extends AbstractCommand
10
{
11
    /**
12
     * @var string
13
     */
14
    protected $siteId;
15
    /**
16
     * @var string
17
     */
18
    protected $resourcePattern;
19
20
    protected function configure()
21
    {
22
        parent::configure();
23
24
        $this
25
            ->setName('site:purge')
26
            ->setDescription('Purge URLs from a given site id')
27
            ->addArgument('site-id', InputArgument::REQUIRED, 'incapsula id of site to purge')
28
            ->addArgument('resource-pattern', InputArgument::OPTIONAL, 'string to match in the URL to be purged', '')
29
        ;
30
    }
31
32
    /**
33
     * @param InputInterface  $input
34
     * @param OutputInterface $output
35
     */
36
    protected function initialize(InputInterface $input, OutputInterface $output)
37
    {
38
        parent::initialize($input, $output);
39
40
        $this->siteId = $input->getArgument('site-id');
41
        $this->resourcePattern = $input->getArgument('resource-pattern');
42
    }
43
44
    /**
45
     * @param InputInterface  $input
46
     * @param OutputInterface $output
47
     *
48
     * @return int
49
     */
50
    protected function execute(InputInterface $input, OutputInterface $output)
51
    {
52
        $this->client->sites()->purgeCache($this->siteId, $this->resourcePattern);
53
54
        return 0;
55
    }
56
}
57