1 | <?php |
||
21 | class Detector |
||
22 | { |
||
23 | /** |
||
24 | * Holds all firewall identification interfaces. |
||
25 | * |
||
26 | * @var FirewallInterface[] |
||
27 | */ |
||
28 | protected $firewalls = []; |
||
29 | |||
30 | /** |
||
31 | * holds the general cURL settings. |
||
32 | * |
||
33 | * @var array |
||
34 | */ |
||
35 | protected $cUrlOptions = [ |
||
36 | CURLOPT_HEADER => 1, |
||
37 | CURLOPT_VERBOSE => 0, |
||
38 | CURLOPT_RETURNTRANSFER => 1, |
||
39 | CURLOPT_USERAGENT => 'Mozilla/5.0 (Windows; U;Windows NT 5.1; ru; rv:1.8.0.9) Gecko/20061206 Firefox/1.5.0.9', |
||
|
|||
40 | CURLOPT_FOLLOWLOCATION => 1, |
||
41 | CURLOPT_SSL_VERIFYPEER => 0, |
||
42 | CURLOPT_SSL_VERIFYHOST => 0, |
||
43 | ]; |
||
44 | |||
45 | /** |
||
46 | * Detector constructor. |
||
47 | * |
||
48 | * @param FirewallInterface[] ...$firewalls |
||
49 | */ |
||
50 | public function __construct(FirewallInterface ...$firewalls) |
||
54 | |||
55 | /** |
||
56 | * creates a report (iterator) of the provided url. |
||
57 | * |
||
58 | * The iterator provides a firewall name as it keys and a checkup-result boolean as it values. |
||
59 | * |
||
60 | * @param string $url |
||
61 | * |
||
62 | * @return \Iterator |
||
63 | */ |
||
64 | public function detect($url) |
||
76 | |||
77 | /** |
||
78 | * fetches the contents of the given url. |
||
79 | * |
||
80 | * @param string $url |
||
81 | * |
||
82 | * @return array [headers=>..., body=>...] |
||
83 | */ |
||
84 | protected function fetch($url) |
||
103 | |||
104 | /** |
||
105 | * marshals the header from a header string. |
||
106 | * |
||
107 | * @param $headerString |
||
108 | * |
||
109 | * @return \Generator |
||
110 | */ |
||
111 | protected function marshalHeaders($headerString) |
||
122 | } |
||
123 |
Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.