Arr   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 34
Duplicated Lines 70.59 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 1
dl 24
loc 34
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getArguments() 12 12 3
A getOptions() 12 12 4

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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