Skip to content

Commit

Permalink
Doc Blocks and Defaults.
Browse files Browse the repository at this point in the history
  • Loading branch information
francis94c committed Apr 18, 2020
1 parent a860d23 commit ad8a440
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions libraries/RESTResponse.php
Expand Up @@ -13,50 +13,62 @@ class RESTResponse extends CI_Controller
// 50*
const INTERNAL_SERVER_ERROR = 500;
const NOT_IMPLEMENTED = 501;

/**
* [protected HTTP Response Code]
* @var int
*/
protected $code;

/**
* [protected Response Data]
* @var mixed
*/
protected $data;

/**
* [protected Shoud Response be JSON Encoded?]
* @var bool
*/
protected $json;
function __construct($data=null, int $code=null)

/**
* [__construct description]
* @date 2020-04-11
* @param [type] $data [description]
* @param integer $code [description]
*/
public function __construct($data=null, ?int $code=null)
{
$this->data = $data;
$this->code = $code;
}

/**
* [__toString description]
* @date 2019-11-09
* @return string [description]
*/
public function __toString():string
{
return !$this->json ? $this->data : n_encode($this->data);
return !$this->json ? $this->data : json_encode($this->data);
}

/**
* [json description]
* @date 2019-11-11
* @param [type] $data [description]
* @param int $code [description]
* @return RESTResponse [description]
*/
public function json($data, int $code):RESTResponse
public function json($data, ?int $code=null):RESTResponse
{
$this->json = true;
$this->code = $code;
$this->data = $data;
return $this;
}

/**
* [send description]
* @date 2019-11-11
Expand Down

0 comments on commit ad8a440

Please sign in to comment.