PHPExiftool\Exiftool::executeCommand PHP Method

executeCommand() public method

Execute a command and return the output
public executeCommand ( string $command ) : string
$command string
return string
    public function executeCommand($command)
    {
        $command = self::getBinary() . ' ' . $command;
        $process = new Process($command);
        $this->logger->addInfo(sprintf('Exiftool executes command %s', $process->getCommandLine()));
        $process->run();
        if (!$process->isSuccessful()) {
            throw new RuntimeException(sprintf('Command %s failed : %s, exitcode %s', $command, $process->getErrorOutput(), $process->getExitCode()));
        }
        $output = $process->getOutput();
        unset($process);
        return $output;
    }

Usage Example

 /**
  * @covers PHPExiftool\Exiftool::executeCommand
  * @covers \PHPExiftool\Exception\RuntimeException
  * @expectedException \PHPExiftool\Exception\RuntimeException
  */
 public function testExecuteCommandFailed()
 {
     $exiftool = new Exiftool($this->getlogger());
     $exiftool->executeCommand('-prout');
 }