Completed
Push — master ( 6d12c1...fefd2b )
by Vincenzo
03:27
created

SlimeCommand::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 6
rs 9.4285
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
3
4
namespace App\Lib\Slime\Console;
5
6
7
use App\Lib\Slime\Interfaces\Console\ConsoleCommand;
8
9
abstract class SlimeCommand implements ConsoleCommand
10
{
11
    protected $mandatoryArgs = [];
12
    protected $acceptedArgs = [];
13
    protected $args = [];
14
15
    public function __construct(array $args)
16
    {
17
        $this->args = $args;
18
19
        $this->parseArgs($args);
20
    }
21
22
    /**
23
     * @return int
24
     */
25
    public abstract function run();
26
27
    private function parseArgs(array $args)
28
    {
29
        foreach ($this->acceptedArgs as $acceptedArg) {
30
            if (array_key_exists($acceptedArg, $args)) {
31
                $this->args[] = $args[$acceptedArg];
32
            }
33
        }
34
    }
35
}