Example #1
0
 /**
  * @return File
  */
 public function getFile()
 {
     if ($this->file) {
         return $this->file;
     }
     // validate
     $this->validate();
     // test if format supported
     if ($this->supportedFormats && !in_array($this->file->getExtension(), $this->supportedFormats)) {
         throw new WrongFormatException('File type not allowed');
     }
     // check checksum
     if ($this->isChecksumValidationAllowed) {
         if ($this->getExpectedChecksum() !== $this->file->getChecksum()) {
             throw new WrongChecksumException('Checksum missmatch');
         }
     }
     // build file
     $this->file = $this->buildFile();
     return $this->file;
 }