Ejemplo n.º 1
0
 /**
  * @param string        $inFilename
  * @param Specification $spec
  * @param string        $outFilename
  *
  * @return string
  * @throws \Exception
  */
 public function convert($inFilename, Specification $spec, $outFilename)
 {
     $converter = $this->resolver->resolve($spec);
     if (!$converter) {
         throw new \Exception("No converter found for specification " . get_class($spec));
     }
     return $converter->convert($inFilename, $spec, $outFilename);
 }
Ejemplo n.º 2
0
 public function testResolveReturnsOnlyAcceptingConverter()
 {
     $converter1 = $this->prophesize(ConverterInterface::class);
     $converter2 = $this->prophesize(ConverterInterface::class);
     $resolver = new ConverterResolver(array($converter1->reveal(), $converter2->reveal()));
     $converter1->accept(Argument::cetera())->willReturn(false);
     $converter2->accept(Argument::cetera())->willReturn(true);
     $extractor = $resolver->resolve(new Image());
     $this->assertSame($converter2->reveal(), $extractor);
 }