Manager   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 100
Duplicated Lines 0 %

Importance

Changes 8
Bugs 0 Features 0
Metric Value
eloc 13
c 8
b 0
f 0
dl 0
loc 100
rs 10
wmc 9

7 Methods

Rating   Name   Duplication   Size   Complexity  
A touch() 0 11 3
A getContents() 0 3 1
A putContents() 0 3 1
A exists() 0 3 1
A getTempDir() 0 3 1
A mkdir() 0 3 1
A rename() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace PrettyBx\Support\Filesystem;
6
7
use Illuminate\Support\Traits\Macroable;
8
9
class Manager
10
{
11
    use Macroable;
0 ignored issues
show
Bug introduced by
The trait Illuminate\Support\Traits\Macroable requires the property $name which is not provided by PrettyBx\Support\Filesystem\Manager.
Loading history...
12
13
    /**
14
     * file_get_contents wrapper
15
     *
16
     * @access	public
17
     * @param	string	$filename	
18
     * @return	mixed
19
     */
20
    public function getContents(string $filename)
21
    {
22
        return file_get_contents($filename);
23
    }
24
25
    /**
26
     * file_put_contents wrapper
27
     *
28
     * @access	public
29
     * @param	string	$filename	
30
     * @param	mixed 	$data    	
31
     * @return	mixed
32
     */
33
    public function putContents(string $filename, $data)
34
    {
35
        return file_put_contents($filename, $data);
36
    }
37
38
    /**
39
     * Returns true if file exists
40
     *
41
     * @access	public
42
     * @param	string	$filename	
43
     * @return	bool
44
     */
45
    public function exists(string $filename): bool
46
    {
47
        return file_exists($filename);
48
    }
49
50
    /**
51
     * mkdir wrapper
52
     *
53
     * @access	public
54
     * @param	string 	$pathname 	
55
     * @param	integer	$mode     	Default: 0777
56
     * @param	boolean	$recursive	Default: false
57
     * @return	bool
58
     */
59
    public function mkdir(string $pathname, int $mode = 0777, bool $recursive = false): bool
60
    {
61
        return mkdir($pathname, $mode, $recursive);
62
    }
63
64
    /**
65
     * rename wrapper
66
     *
67
     * @access	public
68
     * @param	string  	$oldname	
69
     * @param	string  	$newname	
70
     * @param	resource	$context	
71
     * @return	bool
72
     */
73
    public function rename(string $oldname, string $newname, resource $context = null): bool
0 ignored issues
show
Bug introduced by
The type PrettyBx\Support\Filesystem\resource was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
74
    {
75
        return rename($oldname, $newname, $context);
0 ignored issues
show
Bug introduced by
It seems like $context can also be of type PrettyBx\Support\Filesystem\resource; however, parameter $context of rename() does only seem to accept resource, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

75
        return rename($oldname, $newname, /** @scrutinizer ignore-type */ $context);
Loading history...
76
    }
77
78
    /**
79
     * touch wrapper
80
     *
81
     * @access	public
82
     * @param	string	$filename	
83
     * @param	int   	$time    	Default: null
84
     * @param	int   	$atime   	Default: null
85
     * @return	bool
86
     */
87
    public function touch(string $filename, int $time = null, int $atime = null): bool
88
    {
89
        if (empty($time)) {
90
            $time = time();
91
        }
92
93
        if (empty($atime)) {
94
            $atime = time();
95
        }
96
97
        return touch($filename, $time, $atime);
98
    }
99
100
    /**
101
     * getTempDir.
102
     *
103
     * @access	public
104
     * @return	string
105
     */
106
    public function getTempDir(): string
107
    {
108
        return sys_get_temp_dir();
109
    }
110
}