obj = 'ParamSet' == $type ? new Param() : new ServiceInputParams(); if (!empty($fromArray)) { $this->fromArray($fromArray); } if (!empty($booleanIfIsset)) { $this->booleanIfIsset($booleanIfIsset); } } /** * Add parameters from an array. * @param array $data * @return \Workspace\Utility\ServiceInput */ public function fromArray(array $data) { foreach ($data as $key => $item) { $this->obj->$key = $item; } return $this; } /** * Add bolean parameters from an array. * @param array|string $data * @return \Workspace\Utility\ServiceInput */ public function booleanIfIsset($data) { is_array($data) || $data = array($data => true); foreach ($data as $key => $item) { $this->obj->$key = true; } return $this; } /** * Pack parameter set and return parameter object. * @return \Workspace\Utility\Param */ public function pack() { return $this->obj; } } /** * Service input parameter utility to keep options. * @author andre.fourie */ class ServiceInputParams { /** * If value is not set, return false by default. * @param string $name * @return boolean */ public function __get($name) { return false; } public function success($message = '', array $data = array()) { return array( 'RequestId' => $this->requestId, 'Hash' => $this->hash, 'Status' => 'Success', 'Message' => $message, 'Data' => $data ); } public function error($reason = '', $message = '', array $data = array()) { return array( 'RequestId' => $this->requestId, 'Hash' => $this->hash, 'Status' => 'Error', 'StatusReason' => $reason, 'Message' => $message, 'Data' => $data ); } public function deviceSuccess($message = '', array $data = array()) { return array( 'Meta' => array( 'Status' => 'Success', 'Message' => $message ), 'Data' => $data ); } public function deviceError($reason = '', $message = '', array $data = array()) { return array( 'Meta' => array( 'Status' => 'Error', 'StatusReason' => $reason, 'Message' => $message ), 'Data' => $data ); } }