Passed
Push — master ( 09050d...6a0831 )
by Бабичев
04:00
created

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