/** * @param string $gameId * @param string $word * @return Game */ public static function gameStart($gameId, $word) { Assertion::uuid($gameId, "Not a valid uuid"); $game = new Game(); $dateTime = new \DateTime("now"); $game->apply(new GameStarted($gameId, $word, $dateTime)); return $game; }
/** * @test */ public function it_can_start_a_game() { $id = $this->generator->generate(); $this->scenario->when(function () use($id) { return Game::gameStart($id, "puppy"); })->then([new GameStarted($id, "puppy", new \DateTime("now"))]); }
/** * @param GameStart $command */ public function handleGameStart(GameStart $command) { $game = Game::gameStart($command->getGameId(), $command->getWord()); $this->repository->save($game); }
public static function createGame($gameId, $word) { $game = new Game(); $game->apply(new GameStarted($gameId, $word)); return $game; }