ArrayDotCollectionTest   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 72
Duplicated Lines 77.78 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 5
c 1
b 0
f 1
lcom 1
cbo 2
dl 56
loc 72
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A test_collection_gets_null_on_non_existent_path() 0 9 1
A test_collection_gets_shallow_path_value() 11 11 1
A test_collection_gets_nested_path_value() 13 13 1
A test_collection_gets_deep_nested_path_value() 17 17 1
A test_collection_gets_nested_path_with_numeric_keys_value() 15 15 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\ArrayDotCollection;
4
5
class ArrayDotCollectionTest 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
    public function test_collection_gets_null_on_non_existent_path()
8
    {
9
        $collection = [];
10
        $dotter = new ArrayDotCollection;
11
        $expected = null;
12
        $actual = $dotter->get($collection, 'foo');
13
14
        $this->assertEquals($expected, $actual);
15
    }
16
17 View Code Duplication
    public function test_collection_gets_shallow_path_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...
18
    {
19
        $collection = [
20
            'foo' => 'bar',
21
        ];
22
        $dotter = new ArrayDotCollection;
23
        $expected = 'bar';
24
        $actual = $dotter->get($collection, 'foo');
25
26
        $this->assertEquals($expected, $actual);
27
    }
28
29 View Code Duplication
    public function test_collection_gets_nested_path_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...
30
    {
31
        $collection = [
32
            'foo' => [
33
                'bar' => 'acme'
34
            ],
35
        ];
36
        $dotter = new ArrayDotCollection;
37
        $expected = 'acme';
38
        $actual = $dotter->get($collection, 'foo.bar');
39
40
        $this->assertEquals($expected, $actual);
41
    }
42
43 View Code Duplication
    public function test_collection_gets_deep_nested_path_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...
44
    {
45
        $collection = [
46
            'foo' => [
47
                'bar' => [
48
                    'acme' => [
49
                        'name' => 'Acme Corp',
50
                    ]
51
                ]
52
            ],
53
        ];
54
        $dotter = new ArrayDotCollection;
55
        $expected = 'Acme Corp';
56
        $actual = $dotter->get($collection, 'foo.bar.acme.name');
57
58
        $this->assertEquals($expected, $actual);
59
    }
60
61 View Code Duplication
    public function test_collection_gets_nested_path_with_numeric_keys_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...
62
    {
63
        $collection = [
64
            'foo' => [
65
                'bar' => [
66
                    ['name' => 'acme'],
67
                ]
68
            ],
69
        ];
70
        $dotter = new ArrayDotCollection;
71
        $expected = 'acme';
72
        $actual = $dotter->get($collection, 'foo.bar.name');
73
74
        $this->assertEquals($expected, $actual);
75
    }
76
}
77