[
  {
    "path": ".editorconfig",
    "content": "; This file is for unifying the coding style for different editors and IDEs.\n; More information at https://editorconfig.org\n\nroot = true\n\n[*]\ncharset = utf-8\nindent_size = 4\nindent_style = space\nend_of_line = lf\ninsert_final_newline = true\ntrim_trailing_whitespace = true\n\n[*.md]\ntrim_trailing_whitespace = false\n"
  },
  {
    "path": ".gitattributes",
    "content": "# Path-based git attributes\n# https://www.kernel.org/pub/software/scm/git/docs/gitattributes.html\n\n# Ignore all test and documentation with \"export-ignore\".\n/.gitattributes     export-ignore\n/.gitignore         export-ignore\n/.travis.yml        export-ignore\n/phpunit.xml.dist   export-ignore\n/.scrutinizer.yml   export-ignore\n/tests              export-ignore\n/.editorconfig      export-ignore\n"
  },
  {
    "path": ".gitignore",
    "content": "build\ncomposer.lock\ndocs\nvendor\ncoverage\n.phpunit.result.cache\n"
  },
  {
    "path": ".scrutinizer.yml",
    "content": "filter:\n    excluded_paths: [tests/*]\n\nchecks:\n    php:\n        remove_extra_empty_lines: true\n        remove_php_closing_tag: true\n        remove_trailing_whitespace: true\n        fix_use_statements:\n            remove_unused: true\n            preserve_multiple: false\n            preserve_blanklines: true\n            order_alphabetically: true\n        fix_php_opening_tag: true\n        fix_linefeed: true\n        fix_line_ending: true\n        fix_identation_4spaces: true\n        fix_doc_comments: true\n\n"
  },
  {
    "path": ".styleci.yml",
    "content": "preset: laravel\n\ndisabled:\n  - single_class_element_per_statement\n"
  },
  {
    "path": ".travis.yml",
    "content": "language: php\n\nphp:\n  - 7.1\n  - 7.2\n  - 7.3\n  - 8.0\n  - 8.1\n  - 8.2\n  - 8.3\n  - 8.4\n\nenv:\n  matrix:\n    - COMPOSER_FLAGS=\"--prefer-lowest\"\n    - COMPOSER_FLAGS=\"\"\n\nbefore_script:\n  - travis_retry composer self-update\n  - travis_retry composer update ${COMPOSER_FLAGS} --no-interaction --prefer-source\n\nscript:\n  - vendor/bin/phpunit --coverage-text --coverage-clover=coverage.clover\n\nafter_script:\n  - php vendor/bin/ocular code-coverage:upload --format=php-clover coverage.clover\n"
  },
  {
    "path": "CHANGELOG.md",
    "content": "# Changelog\n\nAll notable changes to `guzzle-rate-limiter-middleware` will be documented in this file\n\n## 2.0.1 - 2020-12-19\n\n- add support for PHP 8\n\n## 2.0.0 - 2020-10-06\n\n- Pass a `$limit` parameter in `Store::push`, the signature is now `Store::push(int $timestamp, int $limit)`\n- Allow custom `Deferrer` instances to be passed to `RateLimiterMiddleware::perMinute` and `RateLimiterMiddleware::perSecond`\n\n## 1.0.8 - 2020-07-16\n\n- Allow Guzzle 7\n\n## 1.0.7 - 2020-01-09\n\n- Cast return value of SleepDeferrer to int (#7)\n\n## 1.0.1 - 2019-10-25\n\n- use usleep to ensure sleep actually happens (#5)\n\n## 1.0.0 - 2019-10-08\n\n- initial release\n"
  },
  {
    "path": "LICENSE.md",
    "content": "The MIT License (MIT)\n\nCopyright (c) Spatie bvba <info@spatie.be>\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n"
  },
  {
    "path": "README.md",
    "content": "# A rate limiter middleware for Guzzle\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/spatie/guzzle-rate-limiter-middleware.svg?style=flat-square)](https://packagist.org/packages/spatie/guzzle-rate-limiter-middleware)\n[![Build Status](https://img.shields.io/travis/spatie/guzzle-rate-limiter-middleware/master.svg?style=flat-square)](https://travis-ci.org/spatie/guzzle-rate-limiter-middleware)\n[![Quality Score](https://img.shields.io/scrutinizer/g/spatie/guzzle-rate-limiter-middleware.svg?style=flat-square)](https://scrutinizer-ci.com/g/spatie/guzzle-rate-limiter-middleware)\n[![StyleCI](https://github.styleci.io/repos/165693657/shield?branch=master)](https://github.styleci.io/repos/165693657)\n[![Total Downloads](https://img.shields.io/packagist/dt/spatie/guzzle-rate-limiter-middleware.svg?style=flat-square)](https://packagist.org/packages/spatie/guzzle-rate-limiter-middleware)\n\nA rate limiter middleware for Guzzle. Here's what you need to know:\n\n- Specify a maximum amount of requests per minute or per second\n- When the limit is reached, the process will `sleep` until the request can be made\n- Implement your own driver to persist the rate limiter's request store. This is necessary if the rate limiter needs to work across separate processes, the package ships with an `InMemoryStore`.\n\n## Support us\n\n[<img src=\"https://github-ads.s3.eu-central-1.amazonaws.com/guzzle-rate-limiter-middleware.jpg?t=1\" width=\"419px\" />](https://spatie.be/github-ad-click/guzzle-rate-limiter-middleware)\n\nWe invest a lot of resources into creating [best in class open source packages](https://spatie.be/open-source). You can support us by [buying one of our paid products](https://spatie.be/open-source/support-us).\n\nWe highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on [our contact page](https://spatie.be/about-us). We publish all received postcards on [our virtual postcard wall](https://spatie.be/open-source/postcards).\n\n## Installation\n\nYou can install the package via composer:\n\n```bash\ncomposer require spatie/guzzle-rate-limiter-middleware\n```\n\n## Usage\n\nCreate a [Guzzle middleware stack](http://docs.guzzlephp.org/en/stable/handlers-and-middleware.html) and register it on the client.\n\n```php\nuse GuzzleHttp\\Client;\nuse GuzzleHttp\\HandlerStack;\nuse Spatie\\GuzzleRateLimiterMiddleware\\RateLimiterMiddleware;\n\n$stack = HandlerStack::create();\n$stack->push(RateLimiterMiddleware::perSecond(3));\n\n$client = new Client([\n    'handler' => $stack,\n]);\n```\n\nYou can create a rate limiter to limit per second or per minute.\n\n```php\nRateLimiterMiddleware::perSecond(3); // Max. 3 requests per second\n\nRateLimiterMiddleware::perMinute(5); // Max. 5 requests per minute\n```\n\n## Custom stores\n\nBy default, the rate limiter works in memory. This means that if you have a second PHP process (or Guzzle client) consuming the same API, you'd still possibly hit the rate limit. To work around this issue, the rate limiter's state should be persisted to a cache. Implement the `Store` interface with your own cache, and pass the store to the rate limiter.\n\n```php\nuse MyApp\\RateLimiterStore;\nuse Spatie\\GuzzleRateLimiterMiddleware\\RateLimit;\n\nRateLimiterMiddleware::perSecond(3, new RateLimiterStore());\n```\n\nA Laravel example of a custom `Store`:\n\n```php\n<?php\n\nnamespace MyApp;\n\nuse Spatie\\GuzzleRateLimiterMiddleware\\Store;\nuse Illuminate\\Support\\Facades\\Cache;\n\nclass RateLimiterStore implements Store\n{\n    public function get(): array\n    {\n        return Cache::get('rate-limiter', []);\n    }\n\n    public function push(int $timestamp, int $limit)\n    {\n        Cache::put('rate-limiter', array_merge($this->get(), [$timestamp]));\n    }\n}\n```\n\n### Testing\n\n``` bash\ncomposer test\n```\n\n### Changelog\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.\n\n## Contributing\n\nPlease see [CONTRIBUTING](https://github.com/spatie/.github/blob/main/CONTRIBUTING.md) for details.\n\n### Security\n\nIf you've found a bug regarding security please mail [security@spatie.be](mailto:security@spatie.be) instead of using the issue tracker.\n\n## Postcardware\n\nYou're free to use this package, but if it makes it to your production environment we highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using.\n\nOur address is: Spatie, Kruikstraat 22, 2018 Antwerp, Belgium.\n\nWe publish all received postcards [on our company website](https://spatie.be/en/opensource/postcards).\n\n## Credits\n\n- [Sebastian De Deyne](https://github.com/sebastiandedeyne)\n- [All Contributors](../../contributors)\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information."
  },
  {
    "path": "composer.json",
    "content": "{\n    \"name\": \"spatie/guzzle-rate-limiter-middleware\",\n    \"description\": \"A rate limiter for Guzzle\",\n    \"keywords\": [\n        \"spatie\",\n        \"guzzle-rate-limiter-middleware\"\n    ],\n    \"homepage\": \"https://github.com/spatie/guzzle-rate-limiter-middleware\",\n    \"license\": \"MIT\",\n    \"authors\": [\n        {\n            \"name\": \"Sebastian De Deyne\",\n            \"email\": \"sebastiandedeyne@gmail.com\",\n            \"homepage\": \"https://spatie.be\",\n            \"role\": \"Developer\"\n        }\n    ],\n    \"require\": {\n        \"php\": \"^7.1|^8.0\",\n        \"guzzlehttp/guzzle\": \"^6.3|^7.0\"\n    },\n    \"require-dev\": {\n        \"larapack/dd\": \"^1.0\",\n        \"phpunit/phpunit\": \"^9.3.3\"\n    },\n    \"autoload\": {\n        \"psr-4\": {\n            \"Spatie\\\\GuzzleRateLimiterMiddleware\\\\\": \"src\"\n        }\n    },\n    \"autoload-dev\": {\n        \"psr-4\": {\n            \"Spatie\\\\GuzzleRateLimiterMiddleware\\\\Tests\\\\\": \"tests\"\n        }\n    },\n    \"scripts\": {\n        \"test\": \"vendor/bin/phpunit\",\n        \"test-coverage\": \"vendor/bin/phpunit --coverage-html coverage\"\n\n    },\n    \"config\": {\n        \"sort-packages\": true\n    }\n}\n"
  },
  {
    "path": "phpunit.xml.dist",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<phpunit xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n         xsi:noNamespaceSchemaLocation=\"./vendor/phpunit/phpunit/phpunit.xsd\"\n         bootstrap=\"vendor/autoload.php\"\n         backupGlobals=\"false\"\n         backupStaticAttributes=\"false\"\n         colors=\"true\"\n         verbose=\"true\"\n         convertErrorsToExceptions=\"true\"\n         convertNoticesToExceptions=\"true\"\n         convertWarningsToExceptions=\"true\"\n         processIsolation=\"false\"\n         stopOnFailure=\"false\">\n    <testsuites>\n        <testsuite name=\"Spatie Test Suite\">\n            <directory>tests</directory>\n        </testsuite>\n    </testsuites>\n    <filter>\n        <whitelist>\n            <directory suffix=\".php\">src/</directory>\n        </whitelist>\n    </filter>\n    <logging>\n        <log type=\"tap\" target=\"build/report.tap\"/>\n        <log type=\"junit\" target=\"build/report.junit.xml\"/>\n        <log type=\"coverage-html\" target=\"build/coverage\"/>\n        <log type=\"coverage-text\" target=\"build/coverage.txt\"/>\n        <log type=\"coverage-clover\" target=\"build/logs/clover.xml\"/>\n    </logging>\n</phpunit>\n"
  },
  {
    "path": "src/Deferrer.php",
    "content": "<?php\n\nnamespace Spatie\\GuzzleRateLimiterMiddleware;\n\ninterface Deferrer\n{\n    public function getCurrentTime(): int;\n\n    public function sleep(int $milliseconds);\n}\n"
  },
  {
    "path": "src/InMemoryStore.php",
    "content": "<?php\n\nnamespace Spatie\\GuzzleRateLimiterMiddleware;\n\nclass InMemoryStore implements Store\n{\n    /** @var int[] */\n    protected $timestamps = [];\n\n    public function get(): array\n    {\n        return $this->timestamps;\n    }\n\n    public function push(int $timestamp, int $limit)\n    {\n        $this->timestamps[] = $timestamp;\n    }\n}\n"
  },
  {
    "path": "src/RateLimiter.php",
    "content": "<?php\n\nnamespace Spatie\\GuzzleRateLimiterMiddleware;\n\nclass RateLimiter\n{\n    const TIME_FRAME_MINUTE = 'minute';\n    const TIME_FRAME_SECOND = 'second';\n\n    /** @var int */\n    protected $limit;\n\n    /** @var string */\n    protected $timeFrame;\n\n    /** @var \\Spatie\\RateLimiter\\Store */\n    protected $store;\n\n    /** @var \\Spatie\\GuzzleRateLimiterMiddleware\\Deferrer */\n    protected $deferrer;\n\n    public function __construct(\n        int $limit,\n        string $timeFrame,\n        Store $store,\n        Deferrer $deferrer\n    ) {\n        $this->limit = $limit;\n        $this->timeFrame = $timeFrame;\n        $this->store = $store;\n        $this->deferrer = $deferrer;\n    }\n\n    public function handle(callable $callback)\n    {\n        $delayUntilNextRequest = $this->delayUntilNextRequest();\n\n        if ($delayUntilNextRequest > 0) {\n            $this->deferrer->sleep($delayUntilNextRequest);\n        }\n\n        $this->store->push(\n            $this->deferrer->getCurrentTime(),\n            $this->limit\n        );\n\n        return $callback();\n    }\n\n    protected function delayUntilNextRequest(): int\n    {\n        $currentTimeFrameStart = $this->deferrer->getCurrentTime() - $this->timeFrameLengthInMilliseconds();\n\n        $requestsInCurrentTimeFrame = array_values(array_filter(\n            $this->store->get(),\n            function (int $timestamp) use ($currentTimeFrameStart) {\n                return $timestamp >= $currentTimeFrameStart;\n            }\n        ));\n\n        if (count($requestsInCurrentTimeFrame) < $this->limit) {\n            return 0;\n        }\n\n        $oldestRequestStartTimeRelativeToCurrentTimeFrame =\n            $this->deferrer->getCurrentTime() - $requestsInCurrentTimeFrame[0];\n\n        return $this->timeFrameLengthInMilliseconds() - $oldestRequestStartTimeRelativeToCurrentTimeFrame;\n    }\n\n    protected function timeFrameLengthInMilliseconds(): int\n    {\n        if ($this->timeFrame === self::TIME_FRAME_MINUTE) {\n            return 60 * 1000;\n        }\n\n        return 1000;\n    }\n}\n"
  },
  {
    "path": "src/RateLimiterMiddleware.php",
    "content": "<?php\n\nnamespace Spatie\\GuzzleRateLimiterMiddleware;\n\nuse Psr\\Http\\Message\\RequestInterface;\n\nclass RateLimiterMiddleware\n{\n    /** @var \\Spatie\\GuzzleRateLimiterMiddleware\\RateLimiter */\n    protected $rateLimiter;\n\n    private function __construct(RateLimiter $rateLimiter)\n    {\n        $this->rateLimiter = $rateLimiter;\n    }\n\n    public static function perSecond(int $limit, ?Store $store = null, ?Deferrer $deferrer = null): RateLimiterMiddleware\n    {\n        $rateLimiter = new RateLimiter(\n            $limit,\n            RateLimiter::TIME_FRAME_SECOND,\n            $store ?? new InMemoryStore(),\n            $deferrer ?? new SleepDeferrer()\n        );\n\n        return new static($rateLimiter);\n    }\n\n    public static function perMinute(int $limit, ?Store $store = null, ?Deferrer $deferrer = null): RateLimiterMiddleware\n    {\n        $rateLimiter = new RateLimiter(\n            $limit,\n            RateLimiter::TIME_FRAME_MINUTE,\n            $store ?? new InMemoryStore(),\n            $deferrer ?? new SleepDeferrer()\n        );\n\n        return new static($rateLimiter);\n    }\n\n    public function __invoke(callable $handler)\n    {\n        return function (RequestInterface $request, array $options) use ($handler) {\n            return $this->rateLimiter->handle(function () use ($request, $handler, $options) {\n                return $handler($request, $options);\n            });\n        };\n    }\n}\n"
  },
  {
    "path": "src/SleepDeferrer.php",
    "content": "<?php\n\nnamespace Spatie\\GuzzleRateLimiterMiddleware;\n\nclass SleepDeferrer implements Deferrer\n{\n    public function getCurrentTime(): int\n    {\n        return (int) round(microtime(true) * 1000);\n    }\n\n    public function sleep(int $milliseconds)\n    {\n        usleep($milliseconds * 1000);\n    }\n}\n"
  },
  {
    "path": "src/Store.php",
    "content": "<?php\n\nnamespace Spatie\\GuzzleRateLimiterMiddleware;\n\ninterface Store\n{\n    public function get(): array;\n\n    public function push(int $timestamp, int $limit);\n}\n"
  },
  {
    "path": "tests/RateLimiterMiddlewareTest.php",
    "content": "<?php\n\nnamespace Spatie\\GuzzleRateLimiterMiddleware\\Tests;\n\nuse Spatie\\GuzzleRateLimiterMiddleware\\RateLimiterMiddleware;\n\nclass RateLimiterMiddlewareTest extends TestCase\n{\n    /** @test */\n    public function it_has_named_constructors_to_create_instances()\n    {\n        $this->assertInstanceOf(\n            RateLimiterMiddleware::class,\n            RateLimiterMiddleware::perSecond(5)\n        );\n\n        $this->assertInstanceOf(\n            RateLimiterMiddleware::class,\n            RateLimiterMiddleware::perMinute(5)\n        );\n    }\n}\n"
  },
  {
    "path": "tests/RateLimiterTest.php",
    "content": "<?php\n\nnamespace Spatie\\GuzzleRateLimiterMiddleware\\Tests;\n\nuse Spatie\\GuzzleRateLimiterMiddleware\\RateLimiter;\n\nclass RateLimiterTest extends TestCase\n{\n    /** @test */\n    public function it_execute_actions_below_a_limit_in_seconds()\n    {\n        $rateLimiter = $this->createRateLimiter(3, RateLimiter::TIME_FRAME_SECOND);\n\n        $this->assertEquals(0, $this->deferrer->getCurrentTime());\n\n        $rateLimiter->handle(function () {\n            $this->deferrer->sleep(100);\n        });\n\n        $this->assertEquals(100, $this->deferrer->getCurrentTime());\n\n        $rateLimiter->handle(function () {\n            $this->deferrer->sleep(100);\n        });\n\n        $this->assertEquals(200, $this->deferrer->getCurrentTime());\n\n        $rateLimiter->handle(function () {\n            $this->deferrer->sleep(100);\n        });\n\n        $this->assertEquals(300, $this->deferrer->getCurrentTime());\n\n        $this->deferrer->sleep(700);\n\n        $rateLimiter->handle(function () {\n            $this->deferrer->sleep(100);\n        });\n\n        $this->assertEquals(1100, $this->deferrer->getCurrentTime());\n\n        $rateLimiter->handle(function () {\n            $this->deferrer->sleep(100);\n        });\n\n        $this->assertEquals(1200, $this->deferrer->getCurrentTime());\n    }\n\n    /** @test */\n    public function it_defers_actions_when_it_reaches_a_limit_in_seconds()\n    {\n        $rateLimiter = $this->createRateLimiter(3, RateLimiter::TIME_FRAME_SECOND);\n\n        $this->assertEquals(0, $this->deferrer->getCurrentTime());\n\n        $rateLimiter->handle(function () {\n        });\n\n        $this->assertEquals(0, $this->deferrer->getCurrentTime());\n\n        $rateLimiter->handle(function () {\n        });\n\n        $this->assertEquals(0, $this->deferrer->getCurrentTime());\n\n        $rateLimiter->handle(function () {\n        });\n\n        $this->assertEquals(0, $this->deferrer->getCurrentTime());\n\n        $rateLimiter->handle(function () {\n        });\n\n        $this->assertEquals(1000, $this->deferrer->getCurrentTime());\n    }\n\n    /** @test */\n    public function it_execute_actions_below_a_limit_in_minutes()\n    {\n        $rateLimiter = $this->createRateLimiter(3, RateLimiter::TIME_FRAME_MINUTE);\n\n        $this->assertEquals(0, $this->deferrer->getCurrentTime());\n\n        $rateLimiter->handle(function () {\n            $this->deferrer->sleep(100);\n        });\n\n        $this->assertEquals(100, $this->deferrer->getCurrentTime());\n\n        $rateLimiter->handle(function () {\n            $this->deferrer->sleep(100);\n        });\n\n        $this->assertEquals(200, $this->deferrer->getCurrentTime());\n\n        $rateLimiter->handle(function () {\n            $this->deferrer->sleep(100);\n        });\n\n        $this->assertEquals(300, $this->deferrer->getCurrentTime());\n\n        $this->deferrer->sleep(59700);\n\n        $rateLimiter->handle(function () {\n            $this->deferrer->sleep(100);\n        });\n\n        $this->assertEquals(60100, $this->deferrer->getCurrentTime());\n    }\n\n    /** @test */\n    public function it_defers_actions_when_it_reaches_a_limit_in_minutes()\n    {\n        $rateLimiter = $this->createRateLimiter(3, RateLimiter::TIME_FRAME_MINUTE);\n\n        $this->assertEquals(0, $this->deferrer->getCurrentTime());\n\n        $rateLimiter->handle(function () {\n        });\n\n        $this->assertEquals(0, $this->deferrer->getCurrentTime());\n\n        $rateLimiter->handle(function () {\n        });\n\n        $this->assertEquals(0, $this->deferrer->getCurrentTime());\n\n        $rateLimiter->handle(function () {\n        });\n\n        $this->assertEquals(0, $this->deferrer->getCurrentTime());\n\n        $rateLimiter->handle(function () {\n        });\n\n        $this->assertEquals(60000, $this->deferrer->getCurrentTime());\n    }\n}\n"
  },
  {
    "path": "tests/TestCase.php",
    "content": "<?php\n\nnamespace Spatie\\GuzzleRateLimiterMiddleware\\Tests;\n\nuse PHPUnit\\Framework\\TestCase as BaseTestCase;\nuse Spatie\\GuzzleRateLimiterMiddleware\\InMemoryStore;\nuse Spatie\\GuzzleRateLimiterMiddleware\\RateLimiter;\n\nabstract class TestCase extends BaseTestCase\n{\n    /** @var \\Spatie\\GuzzleRateLimiterMiddleware\\Tests\\TestDeferrer */\n    protected $deferrer;\n\n    protected function setUp(): void\n    {\n        parent::setUp();\n\n        $this->deferrer = new TestDeferrer();\n    }\n\n    public function createRateLimiter(int $limit, string $timeFrame): RateLimiter\n    {\n        return new RateLimiter($limit, $timeFrame, new InMemoryStore(), $this->deferrer);\n    }\n}\n"
  },
  {
    "path": "tests/TestDeferrer.php",
    "content": "<?php\n\nnamespace Spatie\\GuzzleRateLimiterMiddleware\\Tests;\n\nuse Spatie\\GuzzleRateLimiterMiddleware\\Deferrer;\n\nclass TestDeferrer implements Deferrer\n{\n    /** @var int */\n    protected $currentTime = 0;\n\n    public function getCurrentTime(): int\n    {\n        return $this->currentTime;\n    }\n\n    public function sleep(int $milliseconds)\n    {\n        $this->currentTime += $milliseconds;\n    }\n}\n"
  }
]