public function setFile(UploadedFile $file) { if (!$file->isValid()) { throw new UploadException(); } $this->file = $file; }
/** * Check if uploaded file is uploadable and an image. * * @return bool */ private function isUploadableImage() { return $this->file->isValid() && in_array($this->file->getMimeType(), ['image/gif', 'image/jpeg', 'image/png']); }