Fsio::isDir()   A
last analyzed

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 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
namespace Bookdown\Bookdown;
3
4
class Fsio
5
{
6 2
    public function get($file)
7
    {
8 2
        $level = error_reporting(0);
9 2
        $result = file_get_contents($file);
10 2
        error_reporting($level);
11
12 2
        if ($result !== false) {
13 2
            return $result;
14
        }
15
16 1
        $error = error_get_last();
17 1
        throw new Exception($error['message']);
18
    }
19
20 1
    public function put($file, $data)
21
    {
22 1
        $level = error_reporting(0);
23 1
        $result = file_put_contents($file, $data);
24 1
        error_reporting($level);
25
26 1
        if ($result !== false) {
27 1
            return $result;
28
        }
29
30 1
        $error = error_get_last();
31 1
        throw new Exception($error['message']);
32
    }
33
34 2
    public function isDir($dir)
35
    {
36 2
        return is_dir($dir);
37
    }
38
39 1
    public function mkdir($dir, $mode = 0777, $deep = true)
40
    {
41 1
        $level = error_reporting(0);
42 1
        $result = mkdir($dir, $mode, $deep);
43 1
        error_reporting($level);
44
45 1
        if ($result !== false) {
46 1
            return;
47
        }
48
49 1
        $error = error_get_last();
50 1
        throw new Exception($error['message']);
51
    }
52
}
53