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

PlayerDialogOptionCollection::clear()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
c 1
b 0
f 0
dl 0
loc 5
ccs 0
cts 3
cp 0
rs 10
cc 1
nc 1
nop 0
crap 2
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