public function writeCallback($connection, $string)
    {
        $this->content .= $string;

        if (!$this->mime) {
            $this->mime = finfo_buffer($this->finfo, $this->content);

            if (!in_array($this->mime, static::$mimetypes, true)) {
                $this->mime = null;

                return -1;
            }
        }

        if (!($info = getimagesizefromstring($this->content))) {
            return strlen($string);
        }

        $this->info = [
            'width' => $info[0],
            'height' => $info[1],
            'size' => $info[0] * $info[1],
            'mime' => $this->mime,
        ];

        return -1;
    }
public function writeCallback($connection, $string)
    {
        $this->content .= $string;

        if (!$this->mime) {
            $this->mime = finfo_buffer($this->finfo, $this->content);

            if (!in_array($this->mime, static::$mimetypes, true)) {
                $this->mime = null;

                return -1;
            }
        }

        if (!($info = getimagesizefromstring($this->content))) {
            return strlen($string);
        }

        $this->info = [
            'width' => $info[0],
            'height' => $info[1],
            'size' => $info[0] * $info[1],
            'mime' => $this->mime,
        ];

        return -1;
    }
public function writeCallback ( $ connection , $ string ) { $ this -> content .= $ string ; if ( ! $ this -> mime ) { $ this -> mime = finfo_buffer ( $ this -> finfo , $ this -> content ) ; if ( ! in_array ( $ this -> mime , static :: $ mimetypes , true ) ) { $ this -> mime = null ; return - 1 ; } } if ( ! ( $ info = getimagesizefromstring ( $ this -> content ) ) ) { return strlen ( $ string ) ; } $ this -> info = [ 'width' => $ info [ 0 ] , 'height' => $ info [ 1 ] , 'size' => $ info [ 0 ] * $ info [ 1 ] , 'mime' => $ this -> mime , ] ; return - 1 ; }
Callback used to save the first bytes of the body content

@param resource $connection
@param string   $string

return integer
Callback used to save the first bytes of the body content