DotTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 50 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 2
c 1
b 0
f 1
lcom 0
cbo 2
dl 13
loc 26
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A test_dot_resolves_array_collection_and_returns_expected_value() 13 13 1
A test_dot_throws_exception_on_invalid_collection_type() 0 6 1

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
use Enzyme\Freckle\Dot;
4
5
class DotTest extends PHPUnit_Framework_TestCase
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
6
{
7 View Code Duplication
    public function test_dot_resolves_array_collection_and_returns_expected_value()
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...
8
    {
9
        $dot = new Dot;
10
        $collection = [
11
            'foo' => [
12
                'bar' => 'acme',
13
            ]
14
        ];
15
        $expected = 'acme';
16
        $actual = $dot->get($collection, 'foo.bar');
17
18
        $this->assertEquals($expected, $actual);
19
    }
20
21
    /**
22
     * @expectedException \InvalidArgumentException
23
     */
24
    public function test_dot_throws_exception_on_invalid_collection_type()
25
    {
26
        $dot = new Dot;
27
        $collection = 5;
28
        $actual = $dot->get($collection, 'foo.bar');
0 ignored issues
show
Unused Code introduced by
$actual is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
29
    }
30
}
31