SafeBrowsing::IsOkForsafeBrowsing()   A
last analyzed

Complexity

Conditions 5
Paths 6

Size

Total Lines 17
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 5
eloc 11
nc 6
nop 1
dl 0
loc 17
rs 9.6111
c 0
b 0
f 0
1
<?php
2
3
namespace rOpenDev\Google;
4
5
use rOpenDev\curl\CurlRequest;
6
7
class SafeBrowsing
8
{
9
    public $proxy;
10
11
    public static function get($url)
12
    {
13
        $current = new self();
14
15
        return $current->IsOkForsafeBrowsing($url);
16
    }
17
18
    /**
19
     * @return bool
20
     */
21
    public function IsOkForsafeBrowsing($url)
22
    {
23
        $url = 'https://transparencyreport.google.com/transparencyreport/api/v3/safebrowsing/status?site='.$url;
24
        $curl = new CurlRequest($url);
25
        $curl->setDestkopUserAgent();
26
        $curl->setReturnHeader();
27
        if (isset($this->proxy)) {
28
            $curl->setProxy($this->proxy);
29
        }
30
        $output = $curl->execute();
31
        $headers = $curl->getHeader();
32
        if ($curl->hasError() || false !== strpos($output, '<title>Sorry...</title>')) {
33
            return false;
34
        }
35
36
        //return strpos($output, 'Ce site n\'est actuellement pas') !== false ? true : false;
37
        return false !== strpos($headers[0], '200') ? true : false;
38
    }
39
}
40