Completed
Branch master (258150)
by Dev
02:16 queued 26s
created

SafeBrowsing   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 15
dl 0
loc 29
rs 10
c 0
b 0
f 0
wmc 6

2 Methods

Rating   Name   Duplication   Size   Complexity  
A get() 0 5 1
A IsOkForsafeBrowsing() 0 17 5
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
    public function IsOkForsafeBrowsing($url)
20
    {
21
        $url = 'https://transparencyreport.google.com/transparencyreport/api/v3/safebrowsing/status?site='.$url;
22
        $curl = new CurlRequest($url);
23
        $curl->setDestkopUserAgent();
24
        $curl->setReturnHeader();
25
        if (isset($this->proxy)) {
26
            $curl->setProxy($this->proxy);
27
        }
28
        $output = $curl->execute();
29
        $headers = $curl->getHeader();
30
        if ($curl->hasError() || strpos($output, '<title>Sorry...</title>') !== false) {
31
            return false;
32
        }
33
34
        //return strpos($output, 'Ce site n\'est actuellement pas') !== false ? true : false;
35
        return strpos($headers[0], '200') !== false ? true : false;
36
    }
37
}
38