Arr::getArguments()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 12
Code Lines 6

Duplication

Lines 12
Ratio 100 %

Importance

Changes 0
Metric Value
dl 12
loc 12
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 6
nc 3
nop 0
1
<?php namespace nyx\console\input\formats\tokens;
2
3
// External dependencies
4
use nyx\core\collections;
5
6
// Internal dependencies
7
use nyx\console\input;
8
9
/**
10
 * Array Input Tokens
11
 *
12
 * This Tokens collection is able to resolve both Input Arguments and Options by name.
13
 *
14
 * @version     0.1.0
15
 * @author      Michal Chojnacki <[email protected]>
16
 * @copyright   2012-2017 Nyx Dev Team
17
 * @link        https://github.com/unyx/nyx
18
 */
19
class Arr extends collections\Map implements input\formats\interfaces\Tokens
20
{
21
    /**
22
     * {@inheritDoc}
23
     */
24 View Code Duplication
    public function getArguments() : array
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
25
    {
26
        $arguments = [];
27
28
        foreach ($this->items as $name => $value) {
29
            if ($name[0] !== '-') {
30
                $arguments[$name] = $value;
31
            }
32
        }
33
34
        return $arguments;
35
    }
36
37
    /**
38
     * {@inheritDoc}
39
     */
40 View Code Duplication
    public function getOptions() : array
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
41
    {
42
        $options = [];
43
44
        foreach ($this->items as $name => $value) {
45
            if ($name !== '--' && $name[0] === '-') {
46
                $options[$name] = $value;
47
            }
48
        }
49
50
        return $options;
51
    }
52
}
53