FileGetContents::fetch()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 18
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
cc 2
eloc 9
nc 2
nop 1
dl 0
loc 18
ccs 0
cts 9
cp 0
crap 6
rs 9.9666
c 0
b 0
f 0
1
<?php
2
3
/*
4
 * This file is part of CacheTool.
5
 *
6
 * (c) Samuel Gordalina <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace CacheTool\Adapter\Http;
13
14
class FileGetContents extends AbstractHttp
15
{
16
    public function fetch($filename)
17
    {
18
        $url = "{$this->baseUrl}/{$filename}";
19
        $contents = @file_get_contents($url);
20
21
        if (false === $contents) {
22
            return serialize([
23
                'result' => false,
24
                'errors' => [
25
                    [
26
                        'no' => 0,
27
                        'str' => "file_get_contents() call failed with url: ${url}",
28
                    ],
29
                ],
30
            ]);
31
        }
32
33
        return $contents;
34
    }
35
}
36