| Conditions | 4 | 
| Paths | 8 | 
| Total Lines | 26 | 
| Code Lines | 19 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 2 | ||
| Bugs | 0 | Features | 0 | 
| 1 | <?php  | 
            ||
| 26 | public function request($method, $url, $data = null)  | 
            ||
| 27 |     { | 
            ||
| 28 | $options = array(  | 
            ||
| 29 | 'http' => array(  | 
            ||
| 30 | 'timeout' => $this->timeout,  | 
            ||
| 31 | 'method' => $method,  | 
            ||
| 32 | 'header' => "User-Agent: Bouncer Http\r\n"  | 
            ||
| 33 | )  | 
            ||
| 34 | );  | 
            ||
| 35 |         if ($this->apiKey) { | 
            ||
| 36 |             $options['http']['header'] .= "Api-Key: {$this->apiKey}\r\n"; | 
            ||
| 37 | }  | 
            ||
| 38 |         if ($data) { | 
            ||
| 39 | $content = json_encode($data);  | 
            ||
| 40 | $length = strlen($content);  | 
            ||
| 41 | $options['http']['header'] .= "Content-Type: application/json\r\n";  | 
            ||
| 42 |             $options['http']['header'] .= "Content-Length: {$length}\r\n"; | 
            ||
| 43 | $options['http']['content'] = $content;  | 
            ||
| 44 | }  | 
            ||
| 45 | $context = stream_context_create($options);  | 
            ||
| 46 | $result = @file_get_contents($url, false, $context);  | 
            ||
| 47 |         if ($result) { | 
            ||
| 48 | $response = json_decode($result, true);  | 
            ||
| 49 | return $response;  | 
            ||
| 50 | }  | 
            ||
| 51 | }  | 
            ||
| 52 | |||
| 64 |