Code Duplication    Length = 10-11 lines in 2 locations

PackedBoxList.php 2 locations

@@ 69-78 (lines=10) @@
66
        if (!$this->isSorted) {
67
            usort(
68
                $this->list,
69
                function (PackedBox $boxA, PackedBox $boxB) {
70
                    $choice = $boxB->getItems()->count() - $boxA->getItems()->count();
71
                    if ($choice === 0) {
72
                        $choice = $boxA->getBox()->getInnerVolume() - $boxB->getBox()->getInnerVolume();
73
                    }
74
                    if ($choice === 0) {
75
                        $choice = $boxB->getWeight() - $boxA->getWeight();
76
                    }
77
                    return $choice;
78
                }
79
            );
80
            $this->isSorted = true;
81
        }
@@ 89-99 (lines=11) @@
86
     *
87
     * @return int
88
     */
89
    public function reverseCompare(PackedBox $boxA, PackedBox $boxB)
90
    {
91
        $choice = $boxB->getItems()->count() - $boxA->getItems()->count();
92
        if ($choice === 0) {
93
            $choice = $boxA->getBox()->getInnerVolume() - $boxB->getBox()->getInnerVolume();
94
        }
95
        if ($choice === 0) {
96
            $choice = $boxB->getWeight() - $boxA->getWeight();
97
        }
98
        return $choice;
99
    }
100
101
    /**
102
     * Calculate the average (mean) weight of the boxes