Http::get()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 14
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 14
rs 9.4285
cc 2
eloc 11
nc 2
nop 1
1
<?php
2
3
namespace PHPieces\Framework\Util;
4
5
class Http
6
{
7
    public function get($url)
8
    {
9
        if (function_exists("curl_init")) {
10
            $ch = curl_init();
11
            curl_setopt($ch, CURLOPT_URL, $url);
12
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
13
            curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
14
            $content = curl_exec($ch);
15
            curl_close($ch);
16
            return $content;
17
        } else {
18
            return file_get_contents($url);
19
        }
20
    }
21
}
22