Total Complexity | 9 |
Total Lines | 91 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php |
||
11 | class FileOptions |
||
12 | { |
||
13 | /** |
||
14 | * @var Args |
||
15 | */ |
||
16 | private $args; |
||
17 | |||
18 | /** |
||
19 | * @var callable |
||
20 | */ |
||
21 | private $output; |
||
22 | |||
23 | /** |
||
24 | * @var File |
||
25 | */ |
||
26 | private $file; |
||
27 | |||
28 | /** |
||
29 | * bind options |
||
30 | * |
||
31 | * @param Args $args |
||
32 | * @param Streams $streams |
||
33 | * @param File $file |
||
34 | * @return FileOptions |
||
35 | */ |
||
36 | 1 | public static function bind(Args $args, Streams $streams, File $file) |
|
37 | { |
||
38 | 1 | return new self($args, $streams, $file); |
|
39 | } |
||
40 | |||
41 | /** |
||
42 | * FileOptions constructor. |
||
43 | * @param Args $args |
||
44 | * @param callable $output |
||
45 | * @param File $file |
||
46 | */ |
||
47 | 7 | public function __construct(Args $args, $output, File $file) |
|
52 | 7 | } |
|
53 | |||
54 | /** |
||
55 | * run options |
||
56 | * |
||
57 | * @return int|null exit status or null if run was not applicable |
||
58 | */ |
||
59 | 4 | public function run() |
|
60 | { |
||
61 | 4 | $args = $this->args; |
|
62 | |||
63 | 4 | $images = $args->hasOption('images'); |
|
64 | 4 | $show = $args->hasOption('show'); |
|
65 | 4 | $list = $args->hasOption('list'); |
|
66 | |||
67 | 4 | if ($images) { |
|
68 | 1 | return $this->shower()->showImages(); |
|
69 | } |
||
70 | |||
71 | 3 | if ($show) { |
|
72 | 1 | return $this->shower()->showPipelines(); |
|
73 | } |
||
74 | |||
75 | 2 | if ($list) { |
|
76 | 1 | return $this->shower()->showPipelineIds(); |
|
77 | } |
||
78 | |||
79 | 1 | return null; |
|
80 | } |
||
81 | |||
82 | /** |
||
83 | * @param $pipelines |
||
84 | * @return int |
||
85 | */ |
||
86 | 1 | public function showPipelines(File $pipelines) |
|
87 | { |
||
88 | 1 | return $this->shower($pipelines)->showPipelines(); |
|
89 | } |
||
90 | |||
91 | /** |
||
92 | * @param File|null $file [optional] |
||
93 | * @return FileShower |
||
94 | */ |
||
95 | 4 | private function shower(File $file = null) |
|
102 | } |
||
103 | } |
||
104 |