$roundsByTeam */ public function __construct(public array $roundsByTeam) { foreach ($roundsByTeam as $teamId => $count) { if ($teamId === '') { throw new InvalidArgumentException('Objective control team id cannot be empty.'); } if ($count < 0) { throw new InvalidArgumentException('Objective control count cannot be negative.'); } } } public static function empty(): self { return new self([]); } public function recordRound(string $controllerTeamId): self { if ($controllerTeamId === '') { throw new InvalidArgumentException('Controller team id cannot be empty.'); } $next = $this->roundsByTeam; $next[$controllerTeamId] = ($next[$controllerTeamId] ?? 0) + 1; return new self($next); } /** @return array{teamId: string, rounds: int} */ public function forTeam(string $teamId): array { return ['teamId' => $teamId, 'rounds' => $this->roundsByTeam[$teamId] ?? 0]; } }