Code Duplication    Length = 8-9 lines in 7 locations

src/BoxList.php 1 location

@@ 39-46 (lines=8) @@
36
    /**
37
     * @return Traversable
38
     */
39
    public function getIterator(): Traversable
40
    {
41
        if (!$this->isSorted) {
42
            usort($this->list, [$this, 'compare']);
43
            $this->isSorted = true;
44
        }
45
46
        return new ArrayIterator($this->list);
47
    }
48
49
    /**

src/ItemList.php 3 locations

@@ 50-57 (lines=8) @@
47
     *
48
     * @return Item
49
     */
50
    public function extract(): Item
51
    {
52
        if (!$this->isSorted) {
53
            usort($this->list, [$this, 'compare']);
54
            $this->isSorted = true;
55
        }
56
57
        return array_shift($this->list);
58
    }
59
60
    /**
@@ 65-73 (lines=9) @@
62
     *
63
     * @return Item
64
     */
65
    public function top(): Item
66
    {
67
        if (!$this->isSorted) {
68
            usort($this->list, [$this, 'compare']);
69
            $this->isSorted = true;
70
        }
71
        $temp = $this->list;
72
73
        return reset($temp);
74
    }
75
76
    /**
@@ 79-86 (lines=8) @@
76
    /**
77
     * @return Traversable
78
     */
79
    public function getIterator(): Traversable
80
    {
81
        if (!$this->isSorted) {
82
            usort($this->list, [$this, 'compare']);
83
            $this->isSorted = true;
84
        }
85
86
        return new ArrayIterator($this->list);
87
    }
88
89
    /**

src/PackedBoxList.php 2 locations

@@ 46-53 (lines=8) @@
43
    /**
44
     * @return Traversable
45
     */
46
    public function getIterator(): Traversable
47
    {
48
        if (!$this->isSorted) {
49
            usort($this->list, [$this, 'compare']);
50
            $this->isSorted = true;
51
        }
52
53
        return new ArrayIterator($this->list);
54
    }
55
56
    /**
@@ 93-100 (lines=8) @@
90
     *
91
     * @return PackedBox
92
     */
93
    public function top(): PackedBox
94
    {
95
        if (!$this->isSorted) {
96
            usort($this->list, [$this, 'compare']);
97
            $this->isSorted = true;
98
        }
99
100
        return reset($this->list);
101
    }
102
103
    /**

src/PackedItemList.php 1 location

@@ 48-55 (lines=8) @@
45
    /**
46
     * @return Traversable
47
     */
48
    public function getIterator(): Traversable
49
    {
50
        if (!$this->isSorted) {
51
            usort($this->list, [$this, 'compare']);
52
            $this->isSorted = true;
53
        }
54
55
        return new ArrayIterator($this->list);
56
    }
57
58
    /**