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

PurgeSiteCommand   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 14
dl 0
loc 42
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A initialize() 0 6 1
A configure() 0 9 1
A execute() 0 4 1
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
}