Skip to content

Instantly share code, notes, and snippets.

@marcaum54
Created June 10, 2014 19:36
Show Gist options
  • Save marcaum54/b8c55230fc2f395dd6ef to your computer and use it in GitHub Desktop.
Save marcaum54/b8c55230fc2f395dd6ef to your computer and use it in GitHub Desktop.
protected function get400() {
$content = $this->getHttpObject()->getContent();
$erros = json_decode($content, true);
$erro = array();
if (is_array($erros)) {
if (key_exists("Erros", $erros) && is_array($erros["Erros"])){
foreach ($erros["Erros"] as $key => $value) {
array_push($erro, "{$key} - {$value}");
}
} else if (key_exists("Erros", $erros)) {
array_push($erro, $erros["Erros"]);
}
if (key_exists("Mensagem", $erros) && is_array($erros["Mensagem"])){
foreach ($erros["Mensagem"] as $key => $value) {
array_push($erro, "{$key} - {$value}");
}
} else if (key_exists("Mensagem", $erros)){
array_push($erro, $erros["Mensagem"]);
}
} else {
array_push($erro, $content);
}
return new Result(Result::ERROR, NULL, $erro);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment