public function setImagePath($imagePath) { if (!file_exists($imagePath)) { throw new Exception('Invald image path'); } if (!is_readable($imagePath)) { throw new Exception('The file cannot be read'); } $this->imagePath = $imagePath; return $this; }