Passed
Push — master ( b72ef2...c7f67f )
by Бабичев
04:24
created

File::isWritable()   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
c 0
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
3
namespace Bavix\Helpers;
4
5
class File
6
{
7
8
    /**
9
     * @param string $filename
10
     * @param mixed  $contents
11
     *
12
     * @return bool|int
13
     */
14 2
    public static function put($filename, $contents)
15
    {
16 2
        return \file_put_contents($filename, $contents);
17
    }
18
19
    /**
20
     * @param string $source
21
     * @param string $mode
22
     *
23
     * @return bool|resource
24
     */
25 5
    public static function open($source, $mode = 'r')
26
    {
27 5
        return @\fopen($source, $mode . 'b');
28
    }
29
30
    /**
31
     * @param resource $handle
32
     *
33
     * @return bool
34
     */
35 2
    public static function close($handle)
36
    {
37 2
        return \fclose($handle);
38
    }
39
40
    /**
41
     * @param string $path
42
     * @param int    $time
43
     * @param int    $accessTime
44
     *
45
     * @return bool
46
     */
47 2
    public static function touch($path, $time = null, $accessTime = null)
48
    {
49 2
        return @\touch($path, $time, $accessTime);
50
    }
51
52
    /**
53
     * @param string $path
54
     *
55
     * @return bool|string
56
     */
57 3
    public static function real($path)
58
    {
59 3
        return \realpath($path);
60
    }
61
62
    /**
63
     * @param string $path
64
     *
65
     * @return bool
66
     */
67 2
    public static function remove($path)
68
    {
69 2
        return \unlink($path);
70
    }
71
72
    /**
73
     * @param string $path
74
     *
75
     * @return int
76
     */
77 1
    public static function size($path)
78
    {
79 1
        return \filesize($path);
80
    }
81
82
    /**
83
     * @param string $path
84
     *
85
     * @return bool
86
     */
87 1
    public static function exists($path)
88
    {
89 1
        return \file_exists($path);
90
    }
91
92
    /**
93
     * @param string $path
94
     *
95
     * @return bool
96
     */
97 1
    public static function isWritable($path)
98
    {
99 1
        return \is_writable($path);
100
    }
101
102
    /**
103
     * @param string $path
104
     *
105
     * @return bool
106
     */
107 1
    public static function isReadable($path)
108
    {
109 1
        return \is_readable($path);
110
    }
111
112
    /**
113
     * @param string $path
114
     *
115
     * @return bool
116
     */
117 1
    public static function isFile($path)
118
    {
119 1
        return \is_file($path);
120
    }
121
122
    /**
123
     * @param string $path
124
     *
125
     * @return bool
126
     */
127 1
    public static function isLink($path)
128
    {
129 1
        return \is_link($path);
130
    }
131
132
    /**
133
     * @param string $path
134
     * @param string $link
135
     *
136
     * @return bool
137
     */
138 1
    public static function symlink($path, $link)
139
    {
140 1
        return \symlink($path, $link);
141
    }
142
143
}
144