ImmutableHandlersList::remove()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 5
ccs 4
cts 4
cp 1
rs 10
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Flying\HandlersList;
6
7
class ImmutableHandlersList extends HandlersList
8
{
9 1
    public function set(iterable $handlers): self
10
    {
11 1
        return new static($handlers, $this->getConstraint());
12
    }
13
14 1
    public function add(object $handler): self
15
    {
16 1
        return new static([...$this->toArray(), $handler], $this->getConstraint());
17
    }
18
19 1
    public function remove(object $handler): self
20
    {
21 1
        return new static(
22 1
            array_filter($this->toArray(), fn(object $h) => $h !== $handler),
23 1
            $this->getConstraint()
24
        );
25
    }
26
27 1
    public function clear(): self
28
    {
29 1
        return new static([], $this->getConstraint());
30
    }
31
}
32