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
        $this->current = &$this->head;
59
        $this->size++;
60
    }
61
62
    /**
63
     * Inserts at the beginning of the list.

DataStructures/Lists/DoublyLinkedList.php 1 location

@@ 259-273 (lines=15) @@
256
     * @param integer $index the position.
257
     * @param mixed $data the data to store.
258
     */
259
    public function insert($index, $data) {
260
        if($index < 0) {
261
            throw new OutOfBoundsException();
262
        }
263
264
        if($index === 0) {
265
            $this->insertBeginning($data);
266
        } else if($index >= $this->size) {
267
            $this->insertEnd($data);
268
        } else if($index > 0 && $index < $this->size) {
269
            $this->insertAt($index, $data);
270
        }
271
        
272
        $this->size++;
273
    }
274
275
    /**
276
     * Inserts at the beginning of the list.