public function validate(UploadedFile $file, $methods = [self::VALIDATOR_FILE_SET, self::VALIDATOR_FILE_ERRORS, self::VALIDATOR_BLOCK_FILE_TYPES, self::VALIDATOR_MAX_FILE_SIZE])
{
if (in_array(self::VALIDATOR_FILE_ERRORS, $methods) && $file->getError() > 0) {
throw new InvalidFileException(sprintf('The file upload had an error("%s: %s")', $file->getError(), $file->getErrorMessage()));
}
if (in_array(self::VALIDATOR_FILE_SET, $methods) && $file->getFilename() == '') {
throw new UploadFileNotSetException(sprintf('No file "%s" was set', $file->getFilename()));
}
if (in_array(self::VALIDATOR_BLOCK_FILE_TYPES, $methods) && in_array($file->getMimeType(), $this->blockedMimeTypes)) {
throw new InvalidFileTypeException(sprintf('The file type "%s" was blocked', $file->getMimeType()));
}
if (in_array(self::VALIDATOR_MAX_FILE_SIZE, $methods) && $this->maxFileSize !== null && $file->getSize() >= $this->maxFileSize) {
throw new MaxFileSizeExceededException(sprintf('File "%s" exceeds the configured maximum filesize of "%s"', $file->getFilename(), $this->maxFilesize));
}
}