/** * @param string $procedure * @param array $params * * @return RpcRequestPayload * @throws PayloadException */ public static function create($procedure, $params = []) { if (empty($procedure)) { throw PayloadException::emptyProcedure(); } $data = [self::KEY_PROCEDURE => $procedure, self::KEY_PARAMS => $params]; return new self($data); }
/** * @param array $data * * @throws PayloadException */ protected function checkRequiredFieldsPresence($data) { foreach ($this->requiredFields as $requiredField) { if (false == array_key_exists($requiredField, $data)) { throw PayloadException::requiredFieldMissing($requiredField); } } }
/** * @param string|array $response * * @return $this * @throws PayloadException */ public function setResponse($response = '') { if (false == is_string($response) && false == is_array($response)) { throw PayloadException::badResponsePayload(); } $this->data[self::KEY_RESPONSE] = $response; return $this; }