Passed
Pull Request — master (#5)
by Jonas
01:27
created

ArrayHasTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 38.89 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
dl 14
loc 36
rs 10
c 1
b 0
f 0
ccs 16
cts 16
cp 1

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testWillReturnFalseIfNotAvailable() 0 6 1
A testWillReturnTrueIfAvailable() 0 8 1
A testWillFindUsingDotNotation() 14 14 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
namespace ArrayHelpers;
4
5
use PHPUnit\Framework\TestCase;
6
7
class ArrayHasTest extends TestCase
8
{
9 1
    public function testWillReturnFalseIfNotAvailable()
10
    {
11 1
        $data = [];
12 1
        $key = 'foo';
13 1
        $this->assertFalse(
14 1
            Arr::has($data, $key)
15
        );
16 1
    }
17
18 1
    public function testWillReturnTrueIfAvailable()
19
    {
20
        $data = [
21 1
            'foo' => 'fighters',
22
            'bar' => 'tenders',
23
        ];
24 1
        $this->assertTrue(
25 1
            Arr::has($data, 'foo')
26
        );
27 1
    }
28
29 1 View Code Duplication
    public function testWillFindUsingDotNotation()
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
        $data = [
32 1
            'i' => [
33
                "can't" => [
34
                    'get' => [
35
                        'no' => 'satisfaction',
36
                    ],
37
                ],
38
            ],
39
        ];
40 1
        $key = "i.can't.get.no";
41 1
        $this->assertTrue(
42 1
            Arr::has($data, $key)
43
        );
44 1
    }
45
}
46