public function attach($attachmentType, $url)
    {
        $attachmentTypes = [
            AttachmentType::FILE,
            AttachmentType::IMAGE,
            AttachmentType::VIDEO,
            AttachmentType::AUDIO,
        ];

        if (! in_array($attachmentType, $attachmentTypes)) {
            throw CouldNotCreateMessage::invalidAttachmentType();
        }

        if (! isset($url)) {
            throw CouldNotCreateMessage::urlNotProvided();
        }

        $this->attachmentType = $attachmentType;
        $this->attachmentUrl = $url;
        $this->hasAttachment = true;

        return $this;
    }
public function attach($attachmentType, $url)
    {
        $attachmentTypes = [
            AttachmentType::FILE,
            AttachmentType::IMAGE,
            AttachmentType::VIDEO,
            AttachmentType::AUDIO,
        ];

        if (! in_array($attachmentType, $attachmentTypes)) {
            throw CouldNotCreateMessage::invalidAttachmentType();
        }

        if (! isset($url)) {
            throw CouldNotCreateMessage::urlNotProvided();
        }

        $this->attachmentType = $attachmentType;
        $this->attachmentUrl = $url;
        $this->hasAttachment = true;

        return $this;
    }
public function attach ( $ attachmentType , $ url ) { $ attachmentTypes = [ AttachmentType :: FILE , AttachmentType :: IMAGE , AttachmentType :: VIDEO , AttachmentType :: AUDIO , ] ; if ( ! in_array ( $ attachmentType , $ attachmentTypes ) ) { throw CouldNotCreateMessage :: invalidAttachmentType ( ) ; } if ( ! isset ( $ url ) ) { throw CouldNotCreateMessage :: urlNotProvided ( ) ; } $ this -> attachmentType = $ attachmentType ; $ this -> attachmentUrl = $ url ; $ this -> hasAttachment = true ; return $ this ; }
Add Attachment.

@param $attachmentType
@param $url

@throws CouldNotCreateMessage

@return $this
Add Attachment .