Completed
Push — master ( 21d4aa...eb4259 )
by Thijs
02:23
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 touch(string $filename, int $mtime): bool
25
    {
26 1
        return touch($filename, $mtime);
27
    }
28
29 2
    public function getMtime(string $filename): int
30
    {
31 2
        $mtime = @filemtime($filename);
32 2
        if ($mtime === false) {
33 1
            throw new RuntimeException('Could not determine mtime for ' . $filename);
34
            // ... or should we adhere to PHP's int|false convention?
35
        }
36 1
        return $mtime;
37
    }
38
}
39