| Conditions | 5 | 
| Paths | 5 | 
| Total Lines | 36 | 
| Code Lines | 18 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 0 | ||
| 1 | <?php  | 
            ||
| 11 | public function main()  | 
            ||
| 12 |      { | 
            ||
| 13 | $host = 'api.mymemory.translated.net';  | 
            ||
| 14 | |||
| 15 | // Check if host is online.  | 
            ||
| 16 |          if ($this->checkHost($host)) { | 
            ||
| 17 | |||
| 18 | // Host online  | 
            ||
| 19 | $urlString = urlencode($this->string);  | 
            ||
| 20 | $url = "http://$host/get?q=$urlString&langpair=$this->from%7C$this->to";  | 
            ||
| 21 | $json = file_get_contents($url);  | 
            ||
| 22 | $data = json_decode($json);  | 
            ||
| 23 | |||
| 24 | // Checking response status  | 
            ||
| 25 |              if ($data->responseStatus != 200) { | 
            ||
| 26 |                  if ($this->debug == true) { | 
            ||
| 27 | $details = $data->responseDetails;  | 
            ||
| 28 |                      if ($data->responseStatus == 403) { | 
            ||
| 29 | $details = ($data->responseDetails);  | 
            ||
| 30 | }  | 
            ||
| 31 | $this->translation = "<font style='color:red;'>Error ".$data->responseStatus.': '.$details.'</font>';  | 
            ||
| 32 | }  | 
            ||
| 33 | |||
| 34 | return;  | 
            ||
| 35 | }  | 
            ||
| 36 | |||
| 37 | |||
| 38 | $transObtained = $data->responseData->translatedText;  | 
            ||
| 39 | |||
| 40 | $this->translation = ucfirst(strtolower(trim($transObtained)));  | 
            ||
| 41 | |||
| 42 | $this->checkSave();  | 
            ||
| 43 | |||
| 44 | return;  | 
            ||
| 45 | }  | 
            ||
| 46 | }  | 
            ||
| 47 | |||
| 49 |