From 7277ee9a4883dc854735aa072493299daed4d651 Mon Sep 17 00:00:00 2001 From: Dan Feder Date: Wed, 7 Aug 2019 11:37:57 -0500 Subject: [PATCH] Improve state property handling, include timeLimit (#4) --- src/Job/Job.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/Job/Job.php b/src/Job/Job.php index c400cdb..2e7d0ac 100644 --- a/src/Job/Job.php +++ b/src/Job/Job.php @@ -65,9 +65,16 @@ public function getState() return (array) json_decode($this->getResult()->getData()); } - public function getStateProperty($property) + public function getStateProperty(string $property, $default = null) { - return $this->getState()[$property]; + $state = $this->getState(); + if (array_key_exists($property, $state)) { + return $state[$property]; + } elseif (isset($default)) { + return $default; + } else { + return false; + } } public function getResult(): Result @@ -104,7 +111,8 @@ public function jsonSerialize() * @param string $json * JSON string used to hydrate a new instance of the class. */ - public static function hydrate($json) { + public static function hydrate($json) + { $data = json_decode($json); return $data; }