Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
| 1 | <?php |
||
| 7 | class RateLimiterMiddleware |
||
|
|
|||
| 8 | { |
||
| 9 | /** @var \Spatie\GuzzleRateLimiterMiddleware\RateLimiter */ |
||
| 10 | protected $rateLimiter; |
||
| 11 | |||
| 12 | private function __construct(RateLimiter $rateLimiter) |
||
| 16 | |||
| 17 | View Code Duplication | public static function perSecond(int $limit, Store $store = null): RateLimiterMiddleware |
|
| 28 | |||
| 29 | View Code Duplication | public static function perMinute(int $limit, Store $store = null): RateLimiterMiddleware |
|
| 40 | |||
| 41 | public function __invoke(callable $handler) |
||
| 49 | } |
||
| 50 |