RequestTrait   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Test Coverage

Coverage 85.71%

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 14
ccs 6
cts 7
cp 0.8571
rs 10
c 0
b 0
f 0
wmc 5

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getHostByAddr() 0 4 3
A isProxyVisit() 0 5 2
1
<?php
2
3
namespace coderius\hitCounter\traits;
4
5
trait RequestTrait{
6
7 12
    public function isProxyVisit() {
8 12
        if (@fsockopen($_SERVER['REMOTE_ADDR'], 80, $errstr, $errno, 1)) {
9
            return true;
10
        }
11 12
        return false;
12
    }
13
14
15 12
    public function getHostByAddr()
16
    {
17 12
        $remoteAddr = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : null;
18 12
        return $remoteAddr ? gethostbyaddr($remoteAddr) : $remoteAddr;
19
    }
20
}