Created
September 26, 2017 14:07
-
-
Save themakunga/e04aea03745d26ef046533083ffc11a0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
# @Author: Nicolas Martinez <nicolas> | |
# @Date: 2017-09-26T10:40:25-03:00 | |
# @Email: [email protected] | |
# @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