for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace Yiisoft\Yii\RateLimiter\Policy;
use Psr\Http\Message\ServerRequestInterface;
final class LimitPerIp implements LimitPolicyInterface
{
public function fingerprint(ServerRequestInterface $request): string
return sha1(strtolower($request->getMethod() . $request->getUri()->getPath() . $this->getIp($request)));
}
private function getIp(ServerRequestInterface $request): string
/** @psalm-var array{REMOTE_ADDR?: string} $server */
$server = $request->getServerParams();
return $server['REMOTE_ADDR'] ?? '';