From 9a98ac50ff50dda2f2eed1ea825352c50c64440e Mon Sep 17 00:00:00 2001 From: Evgeny Zinoviev Date: Fri, 7 May 2021 23:39:20 +0300 Subject: initial --- src/classes/JobResult.php | 96 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 src/classes/JobResult.php (limited to 'src/classes/JobResult.php') diff --git a/src/classes/JobResult.php b/src/classes/JobResult.php new file mode 100644 index 0000000..c42b6b0 --- /dev/null +++ b/src/classes/JobResult.php @@ -0,0 +1,96 @@ +result = $result; + $this->returnCode = $return_code; + $this->stdout = $stdout; + $this->stderr = $stderr; + $this->signal = $signal; + + return $this; + } + + /** + * @param string $error + * @return $this + */ + public function setError(string $error): JobResult + { + $this->result = Job::RESULT_FAIL; + $this->stderr = $error; + + return $this; + } + + /** + * @return bool + */ + public function isFailed(): bool + { + return $this->result == Job::RESULT_FAIL; + } + + /** + * @return string + */ + public function getStdout(): string + { + return $this->stdout; + } + + /** + * @return mixed|null + */ + public function getStdoutAsJSON() { + $json = jsonDecode($this->stdout); + return $json ? $json : null; + } + + /** + * @return string + */ + public function getError(): string { + return $this->stderr ?? ''; + } + +} \ No newline at end of file -- cgit v1.2.3