| Total Complexity | 10 |
| Total Lines | 62 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php declare(strict_types=1); |
||
| 10 | final class MatchProposal |
||
| 11 | { |
||
| 12 | /** @var ProposalId */ |
||
| 13 | private $id; |
||
| 14 | /** @var AccountId */ |
||
| 15 | private $from; |
||
| 16 | /** @var AccountId */ |
||
| 17 | private $to; |
||
| 18 | /** @var DateTimeInterface */ |
||
| 19 | private $validUntil; |
||
| 20 | /** @var bool */ |
||
| 21 | private $accepted = false; |
||
| 22 | /** @var null|MatchId */ |
||
| 23 | private $match; |
||
| 24 | |||
| 25 | public function __construct( |
||
| 26 | ProposalId $id, |
||
| 27 | AccountId $from, |
||
| 28 | AccountId $to, |
||
| 29 | DateTimeInterface $validUntil |
||
| 30 | ) { |
||
| 31 | $this->id = $id; |
||
| 32 | $this->from = $from; |
||
| 33 | $this->to = $to; |
||
| 34 | $this->validUntil = $validUntil; |
||
| 35 | } |
||
| 36 | |||
| 37 | public function id(): ProposalId |
||
| 38 | { |
||
| 39 | return $this->id; |
||
| 40 | } |
||
| 41 | |||
| 42 | public function canBeAcceptedBy(AccountId $player, DateTimeInterface $when): bool |
||
| 43 | { |
||
| 44 | return !$this->accepted |
||
| 45 | && $this->to->is($player) |
||
| 46 | && $when <= $this->validUntil; |
||
| 47 | } |
||
| 48 | |||
| 49 | public function wasProposedBy(AccountId $account): bool |
||
| 50 | { |
||
| 51 | return $this->from->is($account); |
||
| 52 | } |
||
| 53 | |||
| 54 | public function wasProposedTo(AccountId $account): bool |
||
| 55 | { |
||
| 56 | return $this->to->is($account); |
||
| 57 | } |
||
| 58 | |||
| 59 | public function hasBeenAccepted(): bool |
||
| 62 | } |
||
| 63 | |||
| 64 | public function accept(): void |
||
| 65 | { |
||
| 66 | $this->accepted = true; |
||
| 67 | } |
||
| 68 | |||
| 69 | public function begin(MatchId $match): void |
||
| 72 | } |
||
| 73 | } |
||
| 74 |