public function buildPreview($by)
    {
        if (!in_array($by, $this->previewBys, true)) {
            throw new InvalidArgumentException('This preview by not exist.');
        }

        if (empty($this->msgType)) {
            throw new RuntimeException('Message type not exist.');
        } elseif ($this->msgType === Broadcast::MSG_TYPE_VIDEO) {
            if (is_array($this->message)) {
                $this->message = array_shift($this->message);
            }
            $this->msgType = 'mpvideo';
        }

        if (empty($this->message)) {
            throw new RuntimeException('No message content to send.');
        }

        if (empty($this->to)) {
            throw new RuntimeException('No to.');
        }

        $content = (new Transformer($this->msgType, $this->message))->transform();

        $message = array_merge($this->buildTo($this->to, $by), $content);

        return $message;
    }
public function buildPreview($by)
    {
        if (!in_array($by, $this->previewBys, true)) {
            throw new InvalidArgumentException('This preview by not exist.');
        }

        if (empty($this->msgType)) {
            throw new RuntimeException('Message type not exist.');
        } elseif ($this->msgType === Broadcast::MSG_TYPE_VIDEO) {
            if (is_array($this->message)) {
                $this->message = array_shift($this->message);
            }
            $this->msgType = 'mpvideo';
        }

        if (empty($this->message)) {
            throw new RuntimeException('No message content to send.');
        }

        if (empty($this->to)) {
            throw new RuntimeException('No to.');
        }

        $content = (new Transformer($this->msgType, $this->message))->transform();

        $message = array_merge($this->buildTo($this->to, $by), $content);

        return $message;
    }
public function buildPreview ( $ by ) { if ( ! in_array ( $ by , $ this -> previewBys , true ) ) { throw new InvalidArgumentException ( 'This preview by not exist.' ) ; } if ( empty ( $ this -> msgType ) ) { throw new RuntimeException ( 'Message type not exist.' ) ; } elseif ( $ this -> msgType === Broadcast :: MSG_TYPE_VIDEO ) { if ( is_array ( $ this -> message ) ) { $ this -> message = array_shift ( $ this -> message ) ; } $ this -> msgType = 'mpvideo' ; } if ( empty ( $ this -> message ) ) { throw new RuntimeException ( 'No message content to send.' ) ; } if ( empty ( $ this -> to ) ) { throw new RuntimeException ( 'No to.' ) ; } $ content = ( new Transformer ( $ this -> msgType , $ this -> message ) ) -> transform ( ) ; $ message = array_merge ( $ this -> buildTo ( $ this -> to , $ by ) , $ content ) ; return $ message ; }
Build preview message.

@param string $by

@return array

@throws RuntimeException
@throws InvalidArgumentException
Build preview message .