Conditions | 2 |
Paths | 2 |
Total Lines | 21 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Tests | 13 |
CRAP Score | 2 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
88 | 2 | public function load() |
|
89 | { |
||
90 | 2 | $ch = curl_init(); |
|
91 | |||
92 | 2 | curl_setopt($ch, CURLOPT_URL, $this->url); |
|
93 | 2 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
|
94 | 2 | curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); |
|
95 | 2 | curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1)'); |
|
96 | |||
97 | 2 | $data = curl_exec($ch); |
|
98 | |||
99 | 2 | if ($data === false) { |
|
100 | 1 | throw new Exception( |
|
101 | 1 | sprintf('Error %s when loading data from: %s', curl_error($ch), $this->url) |
|
102 | 1 | ); |
|
103 | } |
||
104 | |||
105 | 1 | curl_close($ch); |
|
106 | |||
107 | 1 | return $data; |
|
108 | } |
||
109 | } |
||
110 |