/** * @param Pub $toBeAdded * @throws \PubAlreadyExistsException */ public function add(\model\Pub $toBeAdded) { foreach ($this->pubs as $pub) { if ($toBeAdded->isSame($pub)) { throw new \PubAlreadyExistsException("Pub already exists"); } } $this->pubs[$toBeAdded->getId()] = $toBeAdded; }
/** * @return string */ private function getBeerTableRows() { $beers = $this->pub->getBeers(); $html = "<thead><tr><th>Namn</th><th>Bryggeri</th><th>Pris</th></thead>"; foreach ($beers as $beer) { $html .= "<tr>"; $html .= "<td><a href='" . $this->navView->getURLToBeer($beer->getID()) . "'>" . $beer->getName() . "</a>"; $html .= "<td>" . $beer->getBrewery() . "</td>"; $html .= "<td>" . $beer->getPrice() . "</td>"; $html .= "</tr>"; } return $html; }
public function isSame(\model\Pub $other) { return $this->id === $other->getId(); }