Completed
Push — master ( 6acfe1...0042b2 )
by Radu
11:51 queued 10s
created

RequestHelper   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 6
c 1
b 0
f 0
dl 0
loc 15
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A getRemoteAddress() 0 13 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace WebServCo\Framework\Helpers;
6
7
final class RequestHelper
8
{
9
    public static function getRemoteAddress(): string
10
    {
11
        if (PhpHelper::isCli()) {
12
            return \gethostbyname(\php_uname('n'));
13
        }
14
15
        // phpcs:ignore SlevomatCodingStandard.Variables.DisallowSuperGlobalVariable.DisallowedSuperGlobalVariable
16
        if (\array_key_exists('REMOTE_ADDR', $_SERVER)) {
17
            // phpcs:ignore SlevomatCodingStandard.Variables.DisallowSuperGlobalVariable.DisallowedSuperGlobalVariable
18
            return \WebServCo\Framework\Utils\Request::sanitizeString($_SERVER['REMOTE_ADDR']);
19
        }
20
21
        return '';
22
    }
23
}
24