Skip to content

Commit

Permalink
Improve state property handling, include timeLimit (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
dafeder authored and fmizzell committed Aug 7, 2019
1 parent dba614f commit 7277ee9
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/Job/Job.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 7277ee9

Please sign in to comment.