| Total Complexity | 4 |
| Total Lines | 25 |
| Duplicated Lines | 0 % |
| Coverage | 90% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 9 | class BasicNetworkResolver implements NetworkResolverInterface |
||
| 10 | { |
||
| 11 | /** |
||
| 12 | * @var ServerRequestInterface|null |
||
| 13 | */ |
||
| 14 | private $serverRequest; |
||
| 15 | |||
| 16 | 2 | public function getRemoteIp(): string |
|
| 17 | { |
||
| 18 | 2 | if($this->serverRequest === null) { |
|
| 19 | throw new \RuntimeException('ServerRequest doesn\'t set, see NetworkResolverInterface::withServerRequest()!'); |
||
| 20 | } |
||
| 21 | 2 | return $this->serverRequest->getServerParams()['REMOTE_ADDR']; |
|
| 22 | } |
||
| 23 | |||
| 24 | 2 | public function getUserIp(): string |
|
| 25 | { |
||
| 26 | 2 | return $this->getRemoteIp(); |
|
| 27 | } |
||
| 28 | |||
| 29 | 2 | public function withServerRequest(ServerRequestInterface $serverRequest) |
|
| 34 | } |
||
| 35 | } |
||
| 36 |