/** * * @return Image */ public function setImage($path) { $image = Image::createFromFile($path); if (!$image) { throw new \InvalidArgumentException(); } if ($this->mWidth !== $image->width || $this->mHeight !== $image->height) { throw new \InvalidArgumentException(); } $this->mImagePath = $path; return $this->mImage = $image; }
/** * * @param LandType $type * @return Image */ public function getTileImage(LandType $type) { if (!isset($this->mTiles[$type->id])) { $path = $this->mTileDirectory . '/' . $type->getImagePath(); $image = Image::createFromFile($path); if ($image->height < $this->getTileHeight()) { throw new \Exception('Invalid tile image height. (' . $this->getTileHeight() . ')'); } if ($image->width != $this->getTileWidth()) { throw new \Exception('Invalid tile image width. (' . $this->getTileWidth() . ')'); } $this->mTiles[$type->id] = $image; } return $this->mTiles[$type->id]; }