Пример #1
0
 public function __construct(AbstractSource $source)
 {
     // copy all the attributes
     $this->fileName = $source->getFileName();
     $this->fileExtension = $source->getFileExtension();
     $this->displayName = $source->getDisplayName();
     $this->filePath = $source->getFilePath();
     $this->fileSize = $source->getFileSize();
     $this->mimeType = $source->getMimeType();
 }
Пример #2
0
 public function check(AbstractSource $source)
 {
     if (empty($this->allowedTypes)) {
         throw new InvalidArgumentException('Allowed mime types can\'t be empty!');
     }
     $mime = strtolower($source->getMimeType());
     if (array_search($mime, $this->allowedTypes) === false) {
         throw new InvalidArgumentException('Mime type ' . $mime . ' is not allowed');
     }
     return true;
 }