Passed
Push — master ( 71afca...9e5fe0 )
by Tom
04:18
created

CacheOptions   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 62
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 10
dl 0
loc 62
ccs 13
cts 13
cp 1
rs 10
c 1
b 0
f 1
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A hasCache() 0 3 1
A bind() 0 3 1
A parse() 0 5 1
A run() 0 5 1
A __construct() 0 3 1
1
<?php
2
3
/* this file is part of pipelines */
4
5
namespace Ktomk\Pipelines\Utility;
6
7
use Ktomk\Pipelines\Cli\Args;
8
9
/**
10
 * aggregated args parser for --no-cache argument parsing.
11
 *
12
 * @package Ktomk\Pipelines\Utility\Args
13
 */
14
class CacheOptions
15
{
16
    /**
17
     * @var null|bool
18
     */
19
    public $noCache;
20
21
    /**
22
     * @var Args
23
     */
24
    private $args;
25
26
    /**
27
     * @param Args $args
28
     *
29
     * @return CacheOptions
30
     */
31 2
    public static function bind(Args $args)
32
    {
33 2
        return new self($args);
34
    }
35
36
    /**
37
     * @param Args $args
38
     */
39 2
    public function __construct(Args $args)
40
    {
41 2
        $this->args = $args;
42 2
    }
43
44
    /**
45
     * @return CacheOptions
46
     */
47 2
    public function run()
48
    {
49 2
        list($this->noCache) = $this->parse($this->args);
50
51 2
        return $this;
52
    }
53
54
    /**
55
     * Parse --no-cache argument
56
     *
57
     * @param Args $args
58
     *
59
     * @throws \InvalidArgumentException
60
     *
61
     * @return array
62
     */
63 2
    public function parse(Args $args)
64
    {
65 2
        $noCache = $args->hasOption('no-cache');
66
67 2
        return array($noCache);
68
    }
69
70
    /**
71
     * @return bool
72
     */
73 1
    public function hasCache()
74
    {
75 1
        return false === $this->noCache;
76
    }
77
}
78