| Total Complexity | 6 |
| Total Lines | 50 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php declare(strict_types=1); |
||
| 8 | final class Block |
||
| 9 | { |
||
| 10 | /** @var int */ |
||
| 11 | private $attacker; |
||
| 12 | /** @var int|null */ |
||
| 13 | private $defender; |
||
| 14 | /** @var int|null */ |
||
| 15 | private $player; |
||
| 16 | /** @var MatchId|null */ |
||
| 17 | private $match; |
||
| 18 | |||
| 19 | public function __construct( |
||
| 20 | int $attacker, |
||
| 21 | ?int $defender, |
||
| 22 | ?int $player, |
||
| 23 | ?MatchId $match |
||
| 24 | ) { |
||
| 25 | $this->attacker = $attacker; |
||
| 26 | $this->defender = $defender; |
||
| 27 | $this->player = $player; |
||
| 28 | $this->match = $match; |
||
| 29 | } |
||
| 30 | |||
| 31 | public static function attacker(int $attacker): self |
||
| 32 | { |
||
| 33 | return new self($attacker, null, null, null); |
||
| 34 | } |
||
| 35 | |||
| 36 | public function withDefender(int $defender): self |
||
| 39 | } |
||
| 40 | |||
| 41 | public function as(int $player): self |
||
| 42 | { |
||
| 43 | return new self($this->attacker, $this->defender, $player, $this->match); |
||
| 44 | } |
||
| 45 | |||
| 46 | public function in(MatchId $match): self |
||
| 47 | { |
||
| 48 | return new self($this->attacker, $this->defender, $this->player, $match); |
||
| 49 | } |
||
| 50 | |||
| 51 | public function go(): BlockTheAttacker |
||
| 58 | ); |
||
| 59 | } |
||
| 60 | } |
||
| 61 |