Splice   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 20
ccs 5
cts 5
cp 1
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A splice() 0 9 2
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