Test Failed
Push — master ( 3b58ea...76dc22 )
by Thijs
01:38
created

FsStorage::put()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 2
crap 1
1
<?php
2
3
namespace lucidtaz\yii2scssphp\storage;
4
5
use RuntimeException;
6
7
class FsStorage implements Storage
8
{
9 1
    public function exists(string $filename): bool
10
    {
11 1
        return file_exists($filename);
12
    }
13
14 1
    public function get(string $filename): string
15
    {
16 1
        return file_get_contents($filename);
17
    }
18
19 1
    public function put(string $filename, string $contents): bool
20
    {
21 1
        return file_put_contents($filename, $contents) !== false;
22
    }
23
24 1
    public function remove(string $filename): bool
25
    {
26 1
        return @unlink($filename);
27
    }
28
29 2
    public function touch(string $filename, int $mtime): bool
30
    {
31 2
        return touch($filename, $mtime);
32 2
    }
33 1
34
    public function getMtime(string $filename): int
35
    {
36 1
        $mtime = @filemtime($filename);
37
        if ($mtime === false) {
38
            throw new RuntimeException('Could not determine mtime for ' . $filename);
39
            // ... or should we adhere to PHP's int|false convention?
40
        }
41
        return $mtime;
42
    }
43
}
44