class ReturnApi {
protected $code;
protected $messages;
protected $data;
public function SetCode($code) {
if (is_int($code)) {
$this->code = $code;
} else {
throw new Exception("Не число");
}
}
public function SetMessage($message) {
if(is_string($message)){
$this->messages = $message;
}else{
throw new Exception("Не строка");
}
}
public function SetData($data) {
if (is_array($data)) {
$this->data = json_encode($data);
} else {
throw new Exception("Не масив");
}
}
public function Ret() {
return json_encode([
"code" => $this->code,
"message" => $this->messages,
"data" => $this->data,
]);
}
}
/**
* Set tag array
*
* @param array $tag
* @return MessagesOptions
*/
public function setTag($tag)
{
$this->tag = (array) $tag;
return $this;
}
/**
* Get tag array
*
* @return array
*/
public function getTag()
{
if (!is_array($this->tag)) {
throw new \InvalidArgumentException(sprintf('"%s" expects array.', __METHOD__));
};
return $this->tag;
}