Passed
Push — master ( a665f8...0b64a5 )
by Paweł
03:11
created

PlayerDialogOptionCollection   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Test Coverage

Coverage 20%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 8
c 1
b 0
f 0
dl 0
loc 27
ccs 2
cts 10
cp 0.2
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A remove() 0 7 1
A clear() 0 5 1
A getType() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace AardsGerds\Game\Dialog;
6
7
use AardsGerds\Game\Shared\Collection;
8
9
final class PlayerDialogOptionCollection extends Collection
10
{
11
    /**
12
     * @note This method mutates state of the collection
13
     */
14
    public function remove(PlayerDialogOption $item): self
15
    {
16
        $this->items = $this->filter(
17
            static fn(PlayerDialogOption $dialogOption): bool => $dialogOption !== $item,
18
        )->getItems();
19
20
        return $this;
21
    }
22
23
    /**
24
     * @note This method mutates state of the collection
25
     */
26
    public function clear(): self
27
    {
28
        $this->items = [];
29
30
        return $this;
31
    }
32
33 1
    protected function getType(): string
34
    {
35 1
        return PlayerDialogOption::class;
36
    }
37
}
38