/** * {@inheritdoc} */ protected function validateSelf() { parent::validateSelf(); if (empty($this->msg)) { throw new InvalidArgumentException('msg must be set.'); } }
/** * {@inheritdoc} */ protected function validateSelf() { parent::validateSelf(); foreach ($this->properties as $prop) { if (empty($this->{$prop})) { throw new InvalidArgumentException("{$prop} can not be null"); } } }
public function build() { $data = ['target_type' => $this->targetType, 'target' => (array) $this->to, 'msg' => $this->msg->toArray(), 'from' => $this->from, 'ext' => $this->ext]; $this->validate($data); return $data; }
/** * Send a message. * * @param Msg $msg * * @return mixed This will return the data field. */ public function send(Msg $msg) { $response = $this->http->post('messages', $msg->build()); return $this->parseResponse($response)['data']; }