mapdev\FacebookMessenger\Exceptions\CouldNotCreateMessage::noAttachmentType PHP Метод

noAttachmentType() публичный статический Метод

public static noAttachmentType ( )
    public static function noAttachmentType()
    {
        return new static('You must define an attachment Type (File,Image,Audio,Video)');
    }

Usage Example

 public function toArray()
 {
     $this->checkRecipient();
     if (is_null($this->attachment_type)) {
         throw CouldNotCreateMessage::noAttachmentType();
     }
     if (is_null($this->attachment_url) && is_null($this->attachment_id)) {
         throw CouldNotCreateMessage::noAttachmentUrl();
     }
     $payload = ['url' => $this->attachment_url];
     if ($this->is_reuseable) {
         $payload['is_reuseable'] = true;
     }
     if (!is_null($this->attachment_id)) {
         $payload = ['attachment_id' => $this->attachment_id];
     }
     return ['recipient' => ['id' => $this->recipient_id], 'message' => ['attachment' => ['type' => $this->attachment_type, 'payload' => $payload]]];
 }