Passed
Push — master ( 0b1636...daadce )
by Paweł
02:53
created

FighterCollection   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
eloc 6
c 0
b 0
f 0
dl 0
loc 16
ccs 0
cts 8
cp 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A order() 0 7 1
A getType() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace AardsGerds\Game\Fight;
6
7
use AardsGerds\Game\Shared\Collection;
8
use function Lambdish\Phunctional\sort;
9
10
final class FighterCollection extends Collection
11
{
12
    public function order(): self
13
    {
14
        return new self(
15
            sort(
16
                static fn(Fighter $one, Fighter $another) =>
17
                    $another->getInitiative()->get() <=> $one->getInitiative()->get(),
18
                $this->items,
19
            ),
20
        );
21
    }
22
23
    protected function getType(): string
24
    {
25
        return Fighter::class;
26
    }
27
}
28