Splice::splice()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 5
c 1
b 0
f 0
nc 2
nop 3
dl 0
loc 9
ccs 5
cts 5
cp 1
crap 2
rs 10
1
<?php
2
3
namespace Cocur\Chain\Link;
4
5
/**
6
 * Splice.
7
 *
8
 * @author    Florian Eckerstorfer
9
 * @copyright 2015-2018 Florian Eckerstorfer
10
 */
11
trait Splice
12
{
13
    /**
14
     * Remove a portion of the array and replace it with something else.
15
     *
16
     * @param int      $offset
17
     * @param int|null $length
18
     * @param array    $replacement
19
     *
20
     * @return self
21
     */
22 9
    public function splice(int $offset, ?int $length = null, $replacement = []): self
23
    {
24 9
        if (func_num_args() > 1) {
25 8
            array_splice($this->array, $offset, $length, $replacement);
26
        } else {
27 1
            array_splice($this->array, $offset);
28
        }
29
30 9
        return $this;
31
    }
32
}
33