Passed
Pull Request — master (#1)
by
unknown
03:38
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
use Incapsula\Api;
9
10
class PurgeSiteCommand extends AbstractCommand{
11
    /**
12
     * @var string
13
     */
14
    protected $siteId;
15
    /**
16
     * @var string
17
     */
18
    protected $resourcePattern;
19
    protected function configure()
20
    {
21
        parent::configure();
22
23
        $this
24
            ->setName('site:purge')
25
            ->setDescription('Purge URLs from a given site id')
26
            ->addArgument('site-id',InputArgument::REQUIRED,'incapsula id of site to purge')
27
            ->addArgument('resource-pattern',InputArgument::OPTIONAL,'string to match in the URL to be purged',"")
28
        ;
29
    }
30
    /**
31
     * @param InputInterface  $input
32
     * @param OutputInterface $output
33
     */
34
    protected function initialize(InputInterface $input, OutputInterface $output)
35
    {
36
        parent::initialize($input, $output);
37
38
        $this->siteId = $input->getArgument('site-id');
39
        $this->resourcePattern = $input->getArgument('resource-pattern');
40
        
41
    }
42
    /**
43
     * @param InputInterface  $input
44
     * @param OutputInterface $output
45
     *
46
     * @return int
47
     */
48
    protected function execute(InputInterface $input, OutputInterface $output)
49
    {
50
        $this->client->sites()->purgeCache($this->siteId,$this->resourcePattern);
51
        return 0;
52
    }
53
}