src/Robtimus/Multipart/Multipart.php
/**
     * Adds a piece of a part.
     * @param string|resource|callable $part The part to add.
     *        If it's a callable it should take a length argument and return a string that is not larger than the input.
     * @param int $length the length of the part, or -1 if not known. Ignored if the part is a string.
     */
Adds a piece of a part.
@param string|resource|callable $part The part to add.
If it's a callable it should take a length argument and return a string that is not larger than the input.
@param int $length the length of the part, or -1 if not known. Ignored if the part is a string.
Adds a piece of a part . @param string|resource|callable $part The part to add . If it ' s a callable it should take a length argument and return a string that is not larger than the input . @param int $length the length of the part or - 1 if not known . Ignored if the part is a string .
private function add($part, $length = -1) {
        if ($this->finished) {
            throw new \LogicException('can\'t add to a finished multipart object');
        }
        if (is_string($part)) {
            $length = strlen($part);
            $this->parts[] = $part;
            $this->partCount++;
            if ($this->contentLength !== -1) {
                $this->contentLength += $length;
            }
        } else if (is_resource($part) || is_callable($part)) {
            $this->parts[] = $part;
            $this->partCount++;
            if ($length === -1) {
                $this->contentLength = -1;
            } else if ($this->contentLength !== -1) {
                $this->contentLength += $length;
            }
        } else {
            throw new \UnexpectedValueException('non-supported part type: ' . gettype($part));
        }
    }
private function add ( $ part , $ length = - 1 ) { if ( $ this -> finished ) { throw new \ LogicException ( 'can\'t add to a finished multipart object' ) ; } if ( is_string ( $ part ) ) { $ length = strlen ( $ part ) ; $ this -> parts [ ] = $ part ; $ this -> partCount ++ ; if ( $ this -> contentLength !== - 1 ) { $ this -> contentLength += $ length ; } } else if ( is_resource ( $ part ) || is_callable ( $ part ) ) { $ this -> parts [ ] = $ part ; $ this -> partCount ++ ; if ( $ length === - 1 ) { $ this -> contentLength = - 1 ; } else if ( $ this -> contentLength !== - 1 ) { $ this -> contentLength += $ length ; } } else { throw new \ UnexpectedValueException ( 'non-supported part type: ' . gettype ( $ part ) ) ; } }
Adds a piece of a part.
Adds a piece of a part .