Players::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

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