1
0
mirror of https://github.com/danog/psalm.git synced 2024-12-13 17:57:37 +01:00
psalm/src/Psalm/Internal/ExecutionEnvironment/SystemCommandExecutor.php
Matthew Brown da42be175f Apply PHPCS fixes
Fixes #1880
2019-07-05 16:27:53 -04:00

36 lines
744 B
PHP

<?php
namespace Psalm\Internal\ExecutionEnvironment;
use function exec;
use function sprintf;
/**
* @author Kitamura Satoshi <with.no.parachute@gmail.com>
* @author Dariusz Rumiński <dariusz.ruminski@gmail.com>
*
* @internal
*/
final class SystemCommandExecutor
{
/**
* Execute command.
*
* @param string $command
*
* @throws \RuntimeException
*
* @return string[]
*/
public function execute(string $command) : array
{
exec($command, $result, $returnValue);
if ($returnValue === 0) {
/** @var string[] */
return $result;
}
throw new \RuntimeException(sprintf('Failed to execute command: %s', $command), $returnValue);
}
}