Filters   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
eloc 9
c 1
b 0
f 0
dl 0
loc 28
ccs 0
cts 17
cp 0
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A googlebotStrict() 0 11 3
A bingbot() 0 3 1
A googlebot() 0 3 1
1
<?php
2
3
namespace PiedWeb\LogsAnalyzer;
4
5
class Filters
6
{
7
    public static $cacheIpGoogle;
8
9
    public static function googlebot($line)
10
    {
11
        return false !== stripos($line->getUserAgent(), 'googlebot');
12
    }
13
14
    /**
15
     * Strict means we check the ip too.
16
     */
17
    public static function googlebotStrict($line)
18
    {
19
        if (false !== stripos($line->getUserAgent(), 'googlebot')) {
20
            if (! isset(self::$cacheIpGoogle[$line->getIp()])) {
21
                self::$cacheIpGoogle[$line->getIp()] = false !== strpos(gethostbyaddr($line->getIp()), 'googlebot');
22
            }
23
24
            return self::$cacheIpGoogle[$line->getIp()];
25
        }
26
27
        return false;
28
    }
29
30
    public static function bingbot($line)
31
    {
32
        return false !== stripos($line->getUserAgent(), 'bingbot');
33
    }
34
}
35