Skip to content

Instantly share code, notes, and snippets.

@themakunga
Created September 26, 2017 14:07
Show Gist options
  • Save themakunga/e04aea03745d26ef046533083ffc11a0 to your computer and use it in GitHub Desktop.
Save themakunga/e04aea03745d26ef046533083ffc11a0 to your computer and use it in GitHub Desktop.
<?php
# @Author: Nicolas Martinez <nicolas>
# @Date: 2017-09-26T10:40:25-03:00
# @Email: pmartinez@allware.cl
# @Filename: OutputHandler.php
# @Last modified by: nicolas
# @Last modified time: 2017-09-26T10:57:19-03:00
/**
*
*/
namespace \DIR\ # change before use it
class OutputHandler
{
function __construct($document)
{
$this->outputmessages = null;
$this->document = $document;
}
public function setOkOut($message){
$arr = array(
'document' => $this->document,
'response' => array(
'timestamp' => date('Y-m-d H:i:s'),
'output' =>'OK',
'message' => $message
)
);
$this->outputmessages[] = $arr;
}
public function setErrorOut($message, $code = null){
$arr = array(
'document' => $this->document,
'response' => array(
'timestamp' => date('Y-m-d H:i:s'),
'output' =>'Error',
'code' => $code,
'message' => $message
)
);
$this->outputmessages[] = $arr;
}
public function getMessages(){
return json_encode($this->outputmessages);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment