/**
  * Constructor
  * @param string          $filename Filename
  * @param FormatInterface $format   Format
  * @param int             $code     Exception code
  * @param \Exception      $previous Previous exception
  */
 public function __construct($filename, FormatInterface $format, $code = 0, \Exception $previous = null)
 {
     $this->filename = $filename;
     $this->format = $format;
     $message = sprintf('There are no available methods to decompress format "%s"', $format->getName());
     parent::__construct($message, $code, $previous);
 }
 /**
  * Constructor.
  * @param MethodInterface $method   Method
  * @param FormatInterface $format   Format
  * @param int             $code     Exception code
  * @param \Exception      $previous Previous exception
  */
 public function __construct(MethodInterface $method, FormatInterface $format, $code = 0, \Exception $previous = null)
 {
     $this->method = $method;
     $this->format = $format;
     $message = sprintf('Method "%s" is not supported for format %s', $method->getName(), $format->getName());
     parent::__construct($message, $code, $previous);
 }
Пример #3
0
 /**
  * Checks the support for a format.
  * @param Format\FormatInterface $format Format
  *
  * @return bool Returns TRUE if the format is supported, FALSE otherwise.
  */
 protected function checkFormatSupport(Format\FormatInterface $format)
 {
     $samples = $format->getSamples();
     if (false === array_key_exists(Format\FormatInterface::SAMPLE_REGULAR, $samples)) {
         return false;
     }
     if (false === file_exists($samples[Format\FormatInterface::SAMPLE_REGULAR])) {
         return false;
     }
     $exitCode = $this->executeCommand('7z t ' . $samples[Format\FormatInterface::SAMPLE_REGULAR]);
     return 0 === $exitCode;
 }
 public function checkUnsupportedFormatUsingMethod(FormatInterface $format)
 {
     $target = $this->getTemporaryPath();
     $this->clearTemporaryPath();
     $file = 'file_ok.' . $format->getExtensions()[0];
     try {
         $this->extract($file, $target, $format);
     } catch (FormatNotSupportedInMethodException $e) {
         $this->assertEquals($format, $e->getFormat());
         $this->assertEquals($this->method, $e->getMethod());
     }
 }