Passed
Pull Request — master (#1)
by
unknown
03:30
created

PurgeSiteCommand::configure()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 6
nc 1
nop 0
dl 0
loc 9
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
     * @var string
12
     */
13
    protected $siteId;
14
    /**
15
     * @var string
16
     */
17
    protected $resourcePattern;
18
    protected function configure()
19
    {
20
        parent::configure();
21
22
        $this
23
            ->setName('site:purge')
24
            ->setDescription('Purge URLs from a given site id')
25
            ->addArgument('site-id', InputArgument::REQUIRED, 'incapsula id of site to purge')
26
            ->addArgument('resource-pattern', InputArgument::OPTIONAL, 'string to match in the URL to be purged',"")
27
        ;
28
    }
29
    /**
30
     * @param InputInterface  $input
31
     * @param OutputInterface $output
32
     */
33
    protected function initialize(InputInterface $input, OutputInterface $output)
34
    {
35
        parent::initialize($input, $output);
36
37
        $this->siteId = $input->getArgument('site-id');
38
        $this->resourcePattern = $input->getArgument('resource-pattern');
39
        
40
    }
41
    /**
42
     * @param InputInterface  $input
43
     * @param OutputInterface $output
44
     *
45
     * @return int
46
     */
47
    protected function execute(InputInterface $input, OutputInterface $output)
48
    {
49
        $this->client->sites()->purgeCache($this->siteId ,$this->resourcePattern);
50
        return 0;
51
    }
52
}