GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 62839f...748982 )
by Sébastien
02:18
created

testAddAppendsItemToCollectionWithNextNumericIndex()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 64
Code Lines 43

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 43
nc 1
nop 0
dl 0
loc 64
rs 9.3956
c 0
b 0
f 0

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
/**
3
 * Novactive Collection.
4
 *
5
 * @author    Luke Visinoni <[email protected], [email protected]>
6
 * @author    Sébastien Morel <[email protected], [email protected]>
7
 * @copyright 2017 Novactive
8
 * @license   MIT
9
 */
10
11
namespace Novactive\Tests;
12
13
use Novactive\Collection\Factory;
14
15
/**
16
 * Class AddCollectionTest.
17
 */
18
class AddCollectionTest extends UnitTestCase
19
{
20
    public function testAddAppendsItemToCollectionWithNextNumericIndex()
21
    {
22
        $array = Factory::create($this->fixtures['array']);
23
        $this->assertEquals(
24
            [
25
                0 => 'first',
26
                1 => 'second',
27
                2 => 'third',
28
            ],
29
            $array->toArray()
30
        );
31
        $array->add('fourth');
32
        $this->assertSame(
33
            [
34
                0 => 'first',
35
                1 => 'second',
36
                2 => 'third',
37
                3 => 'fourth',
38
            ],
39
            $array->toArray()
40
        );
41
        $array->add('fifth');
42
        $this->assertSame(
43
            [
44
                0 => 'first',
45
                1 => 'second',
46
                2 => 'third',
47
                3 => 'fourth',
48
                4 => 'fifth',
49
            ],
50
            $array->toArray()
51
        );
52
53
        $assoc = Factory::create($this->fixtures['assoc']);
54
        $this->assertEquals(
55
            [
56
                '1st' => 'first',
57
                '2nd' => 'second',
58
                '3rd' => 'third',
59
            ],
60
            $assoc->toArray()
61
        );
62
        $assoc->add('fourth');
63
        $this->assertSame(
64
            [
65
                '1st' => 'first',
66
                '2nd' => 'second',
67
                '3rd' => 'third',
68
                0     => 'fourth',
69
            ],
70
            $assoc->toArray()
71
        );
72
        $assoc->add('fifth');
73
        $this->assertSame(
74
            [
75
                '1st' => 'first',
76
                '2nd' => 'second',
77
                '3rd' => 'third',
78
                0     => 'fourth',
79
                1     => 'fifth',
80
            ],
81
            $assoc->toArray()
82
        );
83
    }
84
}
85