Subscript   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 30
Duplicated Lines 40 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 26.67%

Importance

Changes 0
Metric Value
wmc 4
c 0
b 0
f 0
lcom 1
cbo 3
dl 12
loc 30
ccs 4
cts 15
cp 0.2667
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A compile() 12 12 3

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
2
/**
3
 * For licensing information, please see the LICENSE file accompanied with this file.
4
 *
5
 * @author Gerard van Helden <[email protected]>
6
 * @copyright 2012 Gerard van Helden <http://melp.nl>
7
 */
8
9
namespace Zicht\Tool\Script\Node\Expr;
10
11
use Zicht\Tool\Script\Node\Branch;
12
use Zicht\Tool\Script\Node\Node;
13
use Zicht\Tool\Script\Buffer;
14
15
/**
16
 * A subscript node is a node that refers another element inside the node, either though dot notation (a,b) or bracket
17
 * notation (a["b"]).
18
 */
19
class Subscript extends Branch
20
{
21
    /**
22
     * Constructor.
23
     *
24
     * @param Node $n
25
     */
26 3
    public function __construct(Node $n)
27
    {
28 3
        parent::__construct();
29 3
        $this->append($n);
30 3
    }
31
32
33
    /**
34
     * @{inheritDoc}
35
     */
36 View Code Duplication
    public function compile(Buffer $buffer)
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...
37
    {
38
        $buffer->raw('$z->lookup(');
39
        foreach ($this->nodes as $i => $node) {
40
            if ($i > 0) {
41
                $buffer->raw(', ');
42
                $buffer->raw('array(');
43
            }
44
            $node->compile($buffer);
45
        }
46
        $buffer->raw('))');
47
    }
48
}
49