Completed
Push — 1.x-dev ( 423a53...2f7d84 )
by Doug
48:23 queued 46:55
created

BoxListTest   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 63
Duplicated Lines 52.38 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 7
lcom 1
cbo 3
dl 33
loc 63
rs 10
c 2
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testCompare() 18 18 2
A testIssue14A() 15 15 2
B testIssue14B() 0 24 3

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
 * Box packing (3D bin packing, knapsack problem)
4
 * @package BoxPacker
5
 * @author Doug Wright
6
 */
7
8
namespace DVDoug\BoxPacker;
9
10
use DVDoug\BoxPacker\Test\TestBox;
11
use PHPUnit\Framework\TestCase;
12
13
class BoxListTest extends TestCase
14
{
15
16 View Code Duplication
    function testCompare()
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
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...
17
    {
18
19
        $box1 = new TestBox('Small', 21, 21, 3, 1, 20, 20, 2, 100);
20
        $box2 = new TestBox('Large', 201, 201, 21, 1, 200, 200, 20, 1000);
21
        $box3 = new TestBox('Medium', 101, 101, 11, 5, 100, 100, 10, 500);
22
23
        $list = new BoxList;
24
        $list->insert($box1);
25
        $list->insert($box2);
26
        $list->insert($box3);
27
28
        $sorted = [];
29
        while (!$list->isEmpty()) {
30
            $sorted[] = $list->extract();
31
        }
32
        self::assertEquals(array($box1, $box3, $box2), $sorted);
33
    }
34
35 View Code Duplication
    function testIssue14A()
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
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...
36
    {
37
        $box1 = new TestBox('Small', 21, 21, 3, 1, 20, 20, 2, 100);
38
        $box2 = new TestBox('Large', 1301, 1301, 1301, 1, 1300, 1300, 1300, 1000);
39
        $box3 = new TestBox('Medium', 101, 101, 11, 5, 100, 100, 10, 500);
40
        $list = new BoxList;
41
        $list->insert($box1);
42
        $list->insert($box2);
43
        $list->insert($box3);
44
        $sorted = [];
45
        while (!$list->isEmpty()) {
46
            $sorted[] = $list->extract();
47
        }
48
        self::assertEquals(array($box1, $box3, $box2), $sorted);
49
    }
50
51
    function testIssue14B()
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
52
    {
53
        $box1 = new TestBox('Small', 21, 21, 3, 1, 20, 20, 2, 100);
54
        $box2 = new TestBox('Large', 1301, 1301, 1301, 1, 1300, 1300, 1300, 1000);
55
        $box3 = new TestBox('Medium', 101, 101, 11, 5, 100, 100, 10, 500);
56
        $list = new BoxList;
57
        $list->insert($box3);
58
        $list->insert($box2);
59
        $list->insert($box1);
60
        $sorted = [];
61
        while (!$list->isEmpty()) {
62
            $sorted[] = $list->extract();
63
        }
64
        self::assertEquals(array($box1, $box3, $box2), $sorted);
65
        $list = new BoxList;
66
        $list->insert($box2);
67
        $list->insert($box1);
68
        $list->insert($box3);
69
        $sorted = [];
70
        while (!$list->isEmpty()) {
71
            $sorted[] = $list->extract();
72
        }
73
        self::assertEquals(array($box1, $box3, $box2), $sorted);
74
    }
75
}
76