Passed
Push — master ( be90da...e68e96 )
by Paweł
03:02
created

Inventory::remove()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 4
c 0
b 0
f 0
dl 0
loc 7
ccs 0
cts 5
cp 0
rs 10
cc 1
nc 1
nop 1
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace AardsGerds\Game\Inventory;
6
7
use AardsGerds\Game\Shared\Collection;
8
9
final class Inventory extends Collection
10
{
11
    public function filterUsable(): self
12
    {
13
        return $this->filter(
14
            static fn(InventoryItem $inventoryItem): bool => $inventoryItem instanceof Usable,
15
        );
16
    }
17
18
    public function remove(InventoryItem $item): self
19
    {
20
        $this->items = $this->filter(
21
            static fn(InventoryItem $inventoryItem): bool => $inventoryItem !== $item,
22
        )->getItems();
23
24
        return $this;
25
    }
26
27 1
    protected function getType(): string
28
    {
29 1
        return InventoryItem::class;
30
    }
31
}
32