Skip to content

Instantly share code, notes, and snippets.

@Shaked
Created December 20, 2014 17:59
Show Gist options
  • Save Shaked/41c5c7145a9ad87b60a5 to your computer and use it in GitHub Desktop.
Save Shaked/41c5c7145a9ad87b60a5 to your computer and use it in GitHub Desktop.
<?php
namespace Domain;
use Symfony\Component\Validator\Constraints\Null as Null;
class CodeSnifferShellCommand implements ShellCommand {
private $bin;
private $codePath;
private $handleStdOutCallback;
public function __construct($bin, $codePath, callable $handleStdOutCallback) {
$this->bin = $bin;
$this->codePath = $codePath;
$this->handleStdOutCallback = $handleStdOutCallback;
}
/**
* //TODO: use param instead of hardcoded json, requires a parser
* @return string
*/
public function cmd() {
return sprintf(
"%s %s --report=%s",
$this->bin,
$this->codePath,
"json"
);
}
/**
* @return int|null
*/
public function timeout() {
return null;
}
/**
* @param string $output
*/
public function handleStdOut($output) {
$handleStdOutCallback = $this->handleStdOutCallback;
$handleStdOutCallback($output);
}
/**
* @param string $output
*/
public function handleStdErr($output) {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment