public function testAddingGames() { $game1 = new Game(); $game2 = new Game(); $this->match->setGames(array($game1, $game2)); $games = $this->match->getGames(); $this->assertInstanceOf('Doctrine\\Common\\Collections\\ArrayCollection', $games); $this->assertSame($game1, $games[0]); $this->assertSame($game2, $games[1]); }
/** * @param \Application\Model\Entity\Match $match * * @return string */ public function __invoke($match) { $gameResults = array(); $games = $match->getGames(); foreach ($games as $game) { $goalsOne = $game->getGoalsTeamOne(); $goalsTwo = $game->getGoalsTeamTwo(); $gameResults[] = $goalsOne . ":" . $goalsTwo; } return implode(", ", $gameResults); }
/** * Extract values from an object * * @param \Application\Model\Entity\Match $match * * @return array */ public function extract($match) { if ($match instanceof DoubleMatch) { $teamOne = $match->getTeamOne(); $teamTwo = $match->getTeamTwo(); $out = array('games' => $match->getGames()); if ($teamOne) { $out['teamOneAttack'] = $teamOne->getAttackingPlayer()->getId(); $out['teamOneDefence'] = $teamOne->getDefendingPlayer()->getId(); } if ($teamTwo) { $out['teamTwoAttack'] = $teamTwo->getAttackingPlayer()->getId(); $out['teamTwoDefence'] = $teamTwo->getDefendingPlayer()->getId(); } return $out; } else { if ($match instanceof SingleMatch) { return array('games' => $match->getGames()); } } }