original_string: protected function getForwardedIp(ServerRequestInterface $request, $ip)
      {
          $ips = [$ip];
          
          $forwardedFor = $this->splitIps($request->getHeaderLine('X-Forwarded-For'));
          $forwarded = $this->extractForFromForwardedHeader($request->getHeaderLine('Forwarded'));
          $clientIp = $this->splitIps($request->getHeaderLine('Client-Ip'));
          
          if (!$this->areAllTheSame($forwardedFor, $forwarded, $clientIp)) {
              $msg = 'Only one of `X-Forwarded-For`, `Forwarded` or `Client-Ip` headers should be set';
              throw new \RuntimeException($msg);
          }
          
          $fwd = $forwardedFor ?: $forwarded ?: $clientIp;
          
          if ($fwd) {
              $ips = array_merge($ips, $fwd);
          }
          
          return $this->getTrustedForwardedIp($ips);
      }
code: protected function getForwardedIp(ServerRequestInterface $request, $ip)
      {
          $ips = [$ip];
          
          $forwardedFor = $this->splitIps($request->getHeaderLine('X-Forwarded-For'));
          $forwarded = $this->extractForFromForwardedHeader($request->getHeaderLine('Forwarded'));
          $clientIp = $this->splitIps($request->getHeaderLine('Client-Ip'));
          
          if (!$this->areAllTheSame($forwardedFor, $forwarded, $clientIp)) {
              $msg = 'Only one of `X-Forwarded-For`, `Forwarded` or `Client-Ip` headers should be set';
              throw new \RuntimeException($msg);
          }
          
          $fwd = $forwardedFor ?: $forwarded ?: $clientIp;
          
          if ($fwd) {
              $ips = array_merge($ips, $fwd);
          }
          
          return $this->getTrustedForwardedIp($ips);
      }
code_tokens: protected function getForwardedIp ( ServerRequestInterface $ request , $ ip ) { $ ips = [ $ ip ] ; $ forwardedFor = $ this -> splitIps ( $ request -> getHeaderLine ( 'X-Forwarded-For' ) ) ; $ forwarded = $ this -> extractForFromForwardedHeader ( $ request -> getHeaderLine ( 'Forwarded' ) ) ; $ clientIp = $ this -> splitIps ( $ request -> getHeaderLine ( 'Client-Ip' ) ) ; if ( ! $ this -> areAllTheSame ( $ forwardedFor , $ forwarded , $ clientIp ) ) { $ msg = 'Only one of `X-Forwarded-For`, `Forwarded` or `Client-Ip` headers should be set' ; throw new \ RuntimeException ( $ msg ) ; } $ fwd = $ forwardedFor ? : $ forwarded ? : $ clientIp ; if ( $ fwd ) { $ ips = array_merge ( $ ips , $ fwd ) ; } return $ this -> getTrustedForwardedIp ( $ ips ) ; }
docstring: Get the forwarded ip
  
  @param ServerRequestInterface $request
  @param string                 $ip       Connected IP
  @return string|null
docstring_tokens: Get the forwarded ip