Parser::getCommandAndArguments()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 13
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 13
ccs 8
cts 8
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 7
nc 2
nop 1
crap 2
1
<?php
2
3
namespace Buttress\Concrete\Console\Command\Argument;
4
5
class Parser extends \League\CLImate\Argument\Parser
6
{
7
8
    /**
9
     * Pull a command name and arguments from $argv.
10
     *
11
     * @param array $argv
12
     * @return array
13
     */
14 6
    protected function getCommandAndArguments(array $argv = null)
15
    {
16
        // If no $argv is provided then use the global PHP defined $argv.
17 6
        if (is_null($argv)) {
18 3
            global $argv;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
19 2
        }
20
21 6
        $arguments = $argv;
22 6
        $script    = array_shift($arguments);
23 6
        $command   = array_shift($arguments);
24
25 6
        return compact('arguments', 'script', 'command');
26
    }
27
}
28