Conditions | 3 |
Paths | 2 |
Total Lines | 13 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Changes | 3 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
21 | public function getFileSize($path) |
||
22 | { |
||
23 | $ch = curl_init("file://" . rawurlencode($path)); |
||
24 | curl_setopt($ch, CURLOPT_NOBODY, true); |
||
25 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
||
26 | curl_setopt($ch, CURLOPT_HEADER, true); |
||
27 | $data = curl_exec($ch); |
||
28 | curl_close($ch); |
||
29 | if ($data !== false && preg_match('/Content-Length: (\d+)/', $data, $matches)) { |
||
30 | return BigInteger::of($matches[1]); |
||
31 | } |
||
32 | throw new Exception("Curl haven't returned file size."); |
||
33 | } |
||
34 | } |
||
35 |