HEX
Server: LiteSpeed
System: Linux server.zepintelhosting.com 4.18.0 #1 SMP Mon Sep 30 15:36:27 MSK 2024 x86_64
User: enamadmin (1026)
PHP: 8.2.30
Disabled: exec,system,passthru,shell_exec,proc_open,popen,apache_child_terminate
Upload Files
File: /home/enamadmin/public_html/aaelearningb/lib/guzzlehttp/kevinrob/guzzlecache/src/BodyStore.php
<?php

namespace Kevinrob\GuzzleCache;

/**
 *
 * This object is only meant to provide a callable to `GuzzleHttp\Psr7\PumpStream`.
 *
 * @internal don't use it in your project.
 */
class BodyStore
{
    private $body;

    private $read = 0;

    private $toRead;

    public function __construct(string $body)
    {
        $this->body = $body;
        $this->toRead = mb_strlen($this->body);
    }

    /**
     * @param int $length
     * @return false|string
     */
    public function __invoke(int $length)
    {
        if ($this->toRead <= 0) {
            return false;
        }

        $length = min($length, $this->toRead);

        $body = mb_substr(
            $this->body,
            $this->read,
            $length
        );
        $this->toRead -= $length;
        $this->read += $length;
        return $body;
    }
}