test_collection_gets_shallow_path_value()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 7

Duplication

Lines 11
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 11
loc 11
rs 9.4285
cc 1
eloc 7
nc 1
nop 0
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