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

SlimeCommand   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 4
c 0
b 0
f 0
lcom 1
cbo 0
dl 0
loc 27
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
run() 0 1 ?
A parseArgs() 0 8 3
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
}