ImmutableHandlersList   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 7
c 1
b 0
f 0
dl 0
loc 23
ccs 10
cts 10
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A add() 0 3 1
A clear() 0 3 1
A remove() 0 5 1
A set() 0 3 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