Code Duplication    Length = 15-15 lines in 2 locations

DataStructures/Lists/CircularLinkedList.php 1 location

@@ 46-60 (lines=15) @@
43
     * @param integer $index the position.
44
     * @param mixed $data the data to store.
45
     */
46
    public function insert($index, $data) {
47
        if($index < 0) {
48
            throw new OutOfBoundsException();
49
        }
50
51
        if($index === 0) {
52
            $this->insertBeginning($data);
53
        } else if($index >= $this->size) {
54
            $this->insertEnd($data);
55
        } else if($index > 0 && $index < $this->size) {
56
            $this->insertAt($index, $data);
57
        }
58
        
59
        $this->size++;
60
    }
61
62
    /**
63
     * Inserts at the beginning of the list.

DataStructures/Lists/DoublyLinkedList.php 1 location

@@ 182-196 (lines=15) @@
179
     * @param integer $index the position.
180
     * @param mixed $data the data to store.
181
     */
182
    public function insert($index, $data) {
183
        if($index < 0) {
184
            throw new OutOfBoundsException();
185
        }
186
187
        if($index === 0) {
188
            $this->insertBeginning($data);
189
        } else if($index >= $this->size) {
190
            $this->insertEnd($data);
191
        } else if($index > 0 && $index < $this->size) {
192
            $this->insertAt($index, $data);
193
        }
194
        
195
        $this->size++;
196
    }
197
198
    /**
199
     * Inserts at the beginning of the list.