Players   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 6
c 1
b 0
f 1
dl 0
loc 27
rs 10
wmc 7

5 Methods

Rating   Name   Duplication   Size   Complexity  
A current() 0 3 1
A after() 0 3 2
A __construct() 0 3 1
A drawOpeningHands() 0 4 2
A pickRandom() 0 3 1
1
<?php declare(strict_types=1);
2
3
namespace Stratadox\CardGame\Match;
4
5
use function array_rand;
6
use Stratadox\ImmutableCollection\ImmutableCollection;
7
8
final class Players extends ImmutableCollection
9
{
10
    public function __construct(Player ...$players)
11
    {
12
        parent::__construct(...$players);
13
    }
14
15
    public function current(): Player
16
    {
17
        return parent::current();
18
    }
19
20
    public function pickRandom(): int
21
    {
22
        return (int) array_rand($this->items());
23
    }
24
25
    public function drawOpeningHands(MatchId $match): void
26
    {
27
        foreach ($this as $player) {
28
            $player->drawOpeningHand($match);
29
        }
30
    }
31
32
    public function after(int $player): int
33
    {
34
        return $player === 0 ? 1 : 0;
35
    }
36
}
37