function CommandUnishTestCase::getOutputFromJSON

8.0.x CommandUnishTestCase.php CommandUnishTestCase::getOutputFromJSON($key = NULL)
7.x CommandUnishTestCase.php CommandUnishTestCase::getOutputFromJSON($key = NULL)
master CommandUnishTestCase.php CommandUnishTestCase::getOutputFromJSON($key = NULL)

Accessor for the last output, decoded from json.

Parameters

string $key: Optionally return only a top level element from the json object.

Return value

object Decoded object.

File

tests/Unish/CommandUnishTestCase.php, line 142

Namespace

Unish

Class

CommandUnishTestCase

Code

function getOutputFromJSON($key = NULL) {
  $json = json_decode($this->getOutput());
  if (isset($key)) {
    $json = $json->{$key}; // http://stackoverflow.com/questions/2925044/hyphens-in-keys-of-object
  }
  return $json;
}