private function lazyParseStructure(): void
    {
        if (true === $this->structureParsed) {
            return;
        }
        $this->structureParsed = true;

        $this->lazyLoadStructure();

        $this->type = self::$typesMap[$this->structure->type] ?? self::TYPE_UNKNOWN;

        // In our context, \ENCOTHER is as useful as an uknown encoding
        $this->encoding = self::$encodingsMap[$this->structure->encoding] ?? self::ENCODING_UNKNOWN;
        $this->subtype  = $this->structure->subtype;

        if (isset($this->structure->bytes)) {
            $this->bytes = $this->structure->bytes;
        }
        if ($this->structure->ifdisposition) {
            $this->disposition = $this->structure->disposition;
        }
        if ($this->structure->ifdescription) {
            $this->description = $this->structure->description;
        }

        $this->parameters = new Parameters();
        if ($this->structure->ifparameters) {
            $this->parameters->add($this->structure->parameters);
        }

        if ($this->structure->ifdparameters) {
            $this->parameters->add($this->structure->dparameters);
        }

        // When the message is not multipart and the body is the attachment content
        // Prevents infinite recursion
        if (self::isAttachment($this->structure) && !$this instanceof Attachment) {
            $this->parts[] = new Attachment($this->resource, $this->getNumber(), '1', $this->structure);
        }

        if (isset($this->structure->parts)) {
            $parts = $this->structure->parts;
            // https://secure.php.net/manual/en/function.imap-fetchbody.php#89002
            if ($this instanceof Attachment && $this->isEmbeddedMessage() && 1 === \count($parts) && \TYPEMULTIPART === $parts[0]->type) {
                $parts = $parts[0]->parts;
            }
            foreach ($parts as $key => $partStructure) {
                $partNumber = (!$this instanceof Message) ? $this->partNumber . '.' : '';
                $partNumber .= (string) ($key + 1);

                $newPartClass = self::isAttachment($partStructure)
                    ? Attachment::class
                    : SimplePart::class
                ;

                $this->parts[] = new $newPartClass($this->resource, $this->getNumber(), $partNumber, $partStructure);
            }
        }
    }
private function lazyParseStructure(): void
    {
        if (true === $this->structureParsed) {
            return;
        }
        $this->structureParsed = true;

        $this->lazyLoadStructure();

        $this->type = self::$typesMap[$this->structure->type] ?? self::TYPE_UNKNOWN;

        // In our context, \ENCOTHER is as useful as an uknown encoding
        $this->encoding = self::$encodingsMap[$this->structure->encoding] ?? self::ENCODING_UNKNOWN;
        $this->subtype  = $this->structure->subtype;

        if (isset($this->structure->bytes)) {
            $this->bytes = $this->structure->bytes;
        }
        if ($this->structure->ifdisposition) {
            $this->disposition = $this->structure->disposition;
        }
        if ($this->structure->ifdescription) {
            $this->description = $this->structure->description;
        }

        $this->parameters = new Parameters();
        if ($this->structure->ifparameters) {
            $this->parameters->add($this->structure->parameters);
        }

        if ($this->structure->ifdparameters) {
            $this->parameters->add($this->structure->dparameters);
        }

        // When the message is not multipart and the body is the attachment content
        // Prevents infinite recursion
        if (self::isAttachment($this->structure) && !$this instanceof Attachment) {
            $this->parts[] = new Attachment($this->resource, $this->getNumber(), '1', $this->structure);
        }

        if (isset($this->structure->parts)) {
            $parts = $this->structure->parts;
            // https://secure.php.net/manual/en/function.imap-fetchbody.php#89002
            if ($this instanceof Attachment && $this->isEmbeddedMessage() && 1 === \count($parts) && \TYPEMULTIPART === $parts[0]->type) {
                $parts = $parts[0]->parts;
            }
            foreach ($parts as $key => $partStructure) {
                $partNumber = (!$this instanceof Message) ? $this->partNumber . '.' : '';
                $partNumber .= (string) ($key + 1);

                $newPartClass = self::isAttachment($partStructure)
                    ? Attachment::class
                    : SimplePart::class
                ;

                $this->parts[] = new $newPartClass($this->resource, $this->getNumber(), $partNumber, $partStructure);
            }
        }
    }
private function lazyParseStructure ( ) : void { if ( true === $ this -> structureParsed ) { return ; } $ this -> structureParsed = true ; $ this -> lazyLoadStructure ( ) ; $ this -> type = self :: $ typesMap [ $ this -> structure -> type ] ?? self :: TYPE_UNKNOWN ; // In our context, \ENCOTHER is as useful as an uknown encoding $ this -> encoding = self :: $ encodingsMap [ $ this -> structure -> encoding ] ?? self :: ENCODING_UNKNOWN ; $ this -> subtype = $ this -> structure -> subtype ; if ( isset ( $ this -> structure -> bytes ) ) { $ this -> bytes = $ this -> structure -> bytes ; } if ( $ this -> structure -> ifdisposition ) { $ this -> disposition = $ this -> structure -> disposition ; } if ( $ this -> structure -> ifdescription ) { $ this -> description = $ this -> structure -> description ; } $ this -> parameters = new Parameters ( ) ; if ( $ this -> structure -> ifparameters ) { $ this -> parameters -> add ( $ this -> structure -> parameters ) ; } if ( $ this -> structure -> ifdparameters ) { $ this -> parameters -> add ( $ this -> structure -> dparameters ) ; } // When the message is not multipart and the body is the attachment content // Prevents infinite recursion if ( self :: isAttachment ( $ this -> structure ) && ! $ this instanceof Attachment ) { $ this -> parts [ ] = new Attachment ( $ this -> resource , $ this -> getNumber ( ) , '1' , $ this -> structure ) ; } if ( isset ( $ this -> structure -> parts ) ) { $ parts = $ this -> structure -> parts ; // https://secure.php.net/manual/en/function.imap-fetchbody.php#89002 if ( $ this instanceof Attachment && $ this -> isEmbeddedMessage ( ) && 1 === \ count ( $ parts ) && \ TYPEMULTIPART === $ parts [ 0 ] -> type ) { $ parts = $ parts [ 0 ] -> parts ; } foreach ( $ parts as $ key => $ partStructure ) { $ partNumber = ( ! $ this instanceof Message ) ? $ this -> partNumber . '.' : '' ; $ partNumber .= ( string ) ( $ key + 1 ) ; $ newPartClass = self :: isAttachment ( $ partStructure ) ? Attachment :: class : SimplePart :: class ; $ this -> parts [ ] = new $ newPartClass ( $ this -> resource , $ this -> getNumber ( ) , $ partNumber , $ partStructure ) ; } } }
Parse part structure.
Parse part structure .