/** * Create process object * * @param string $inputFile * * @throws \RuntimeException * * @return Process */ public function createProcess($inputFile) { if (!is_file($inputFile)) { throw new \RuntimeException('Input file does not exist'); } $arguments = array_values($this->arguments->toArray()); array_push($arguments, '-f', $inputFile); return $this->builder->setArguments($arguments)->getProcess(); }
/** * Create process arguments. * * @param Input $input * * @throws \RuntimeException * * @return array */ protected function createProcessArguments(Input $input) { $arguments = array_values($this->arguments->toArray()); if (null !== $input->getPostScriptCode()) { array_push($arguments, '-c', $input->getPostScriptCode()); } if (count($input->getFiles()) > 0) { array_push($arguments, '-f'); foreach ($input->getFiles() as $file) { if (!is_file($file)) { throw new \RuntimeException('Input file does not exist'); } array_push($arguments, $file); } } if (null !== $input->getProcessInput()) { array_push($arguments, '-'); } return $arguments; }
/** * @dataProvider provideArgumentsForSetting * * @param array $arguments * @param array $expected */ public function testSettingArguments($arguments, $expected) { $instance = new Arguments(); $instance->setArguments($arguments); $this->assertEquals($expected, $instance->toArray()); }