paragraph1\phpFCM\Message::jsonSerialize PHP Method

jsonSerialize() public method

public jsonSerialize ( )
    public function jsonSerialize()
    {
        $jsonData = array();
        if (empty($this->recipients)) {
            throw new \UnexpectedValueException('message must have at least one recipient');
        }
        $this->createTo($jsonData);
        if ($this->collapseKey) {
            $jsonData['collapse_key'] = $this->collapseKey;
        }
        if ($this->data) {
            $jsonData['data'] = $this->data;
        }
        if ($this->priority) {
            $jsonData['priority'] = $this->priority;
        }
        if ($this->notification) {
            $jsonData['notification'] = $this->notification;
        }
        if ($this->timeToLive) {
            $jsonData['time_to_live'] = (int) $this->timeToLive;
        }
        if ($this->delayWhileIdle) {
            $jsonData['delay_while_idle'] = (bool) $this->delayWhileIdle;
        }
        if ($this->contentAvailableFlag === TRUE) {
            $jsonData['content_available'] = TRUE;
        }
        return $jsonData;
    }