/** * 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); }
public function checkSupportedInvalidFormatUsingMethod(FormatInterface $format) { $target = $this->getTemporaryPath(); $this->clearTemporaryPath(); try { $this->extract('file_fake.zip', $target, $format); } catch (FileCorruptedException $e) { $this->assertEquals($this->filesPath . 'file_fake.zip', $e->getFilename()); $this->assertEquals(FileCorruptedException::SEVERITY_HIGH, $e->getSeverity()); return; } $errorMessage = sprintf('Expected exception has not been thrown: %s should throw a FileCorruptedException for %s', $this->method->getName(), $format->getName()); $this->assertFalse(true, $errorMessage); $this->clearTemporaryPath(); }
protected function extract($file, $target, FormatInterface $format) { return $this->method->extract($this->filesPath . $file, $target, $format); }