public function saveAttachments($options = null)
    {
        if(!isset($options['dir'])){
            $dir = __DIR__.DIRECTORY_SEPARATOR;
        }else{
            $dir = $options['dir'];
        };
        if(!isset($options['incomingMessage'])){
            $incomingMessage = $this->incomingMessage;
        }else{
            $incomingMessage = $options['incomingMessage'];
        };
        foreach ($incomingMessage->attachments as $key => $attachment) {
            $newFileName = $attachment->name;
            file_put_contents($dir.DIRECTORY_SEPARATOR.$newFileName, $attachment->body);
        };
    }
public function saveAttachments($options = null)
    {
        if(!isset($options['dir'])){
            $dir = __DIR__.DIRECTORY_SEPARATOR;
        }else{
            $dir = $options['dir'];
        };
        if(!isset($options['incomingMessage'])){
            $incomingMessage = $this->incomingMessage;
        }else{
            $incomingMessage = $options['incomingMessage'];
        };
        foreach ($incomingMessage->attachments as $key => $attachment) {
            $newFileName = $attachment->name;
            file_put_contents($dir.DIRECTORY_SEPARATOR.$newFileName, $attachment->body);
        };
    }
public function saveAttachments ( $ options = null ) { if ( ! isset ( $ options [ 'dir' ] ) ) { $ dir = __DIR__ . DIRECTORY_SEPARATOR ; } else { $ dir = $ options [ 'dir' ] ; } ; if ( ! isset ( $ options [ 'incomingMessage' ] ) ) { $ incomingMessage = $ this -> incomingMessage ; } else { $ incomingMessage = $ options [ 'incomingMessage' ] ; } ; foreach ( $ incomingMessage -> attachments as $ key => $ attachment ) { $ newFileName = $ attachment -> name ; file_put_contents ( $ dir . DIRECTORY_SEPARATOR . $ newFileName , $ attachment -> body ) ; } ; }
Save attachments one incoming message

The allowed types are TypeAttachments
You can add your own

@param array $options.
$options['dir'] it is directory for save attachments.
$options['incomingMessage'] it is incomingMessage object
@return void
Save attachments one incoming message