class JSON_Response{
private $ResponseCode = "RVN-775";
private $ResponseDescription = "Unknown Request";
private $ResponseOf = "Unknown";
private $ResponsePayload = array("PayloadEmpty"->"Yes");
function __construct(
$ResponseCode = null,
$ResponseDescription = null,
$ResponseOf = null,
$ResponsePayload = null,
)
{
$this->ResponseCode = $ResponseCode ? $ResponseCode : $this->ResponseCode;
$this->ResponseDescription = $ResponseDescription ? $ResponseDescription : $this->ResponseDescription;
$this->ResponseOf = $ResponseOf ? $ResponseOf : $this->ResponseOf;
$this->ResponsePayload = $ResponsePayload ? $ResponsePayload : $this->ResponsePayload;
}
}
Is there any better way to write this?
I want the class variables to be set if constructor gets parameters when object is created, if no parameters are given then I want the class variables to be default.