for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php declare(strict_types=1);
namespace Stratadox\CardGame\ReadModel\Match;
use function array_key_exists;
use Stratadox\CardGame\Match\MatchId;
class Battlefields
{
private $battlefields = [];
public function for(MatchId $match): Battlefield
if (!array_key_exists($match->id(), $this->battlefields)) {
$this->battlefields[$match->id()] = Battlefield::untouched();
}
return $this->battlefields[$match->id()];
/** @return Card[] */
public function cardsInPlay(MatchId $match): array
return $this->for($match)->cardsInPlay();
public function cardsInPlayFor(int $player, MatchId $match): array
return $this->for($match)->cardsInPlayFor($player);
public function attackers(MatchId $match): array
return $this->for($match)->attackers();
public function defenders(MatchId $match): array
return $this->for($match)->defenders();