Passed
Push — main ( 2c37f6...88fc45 )
by Sammy
01:19
created
FileSystem.class.php 1 patch
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -17,23 +17,23 @@  discard block
 block discarded – undo
17 17
     return $this->root_path.'/'.$filename;
18 18
   }
19 19
 
20
-  public function filenames($regex=null) : array
20
+  public function filenames($regex = null) : array
21 21
   {
22
-		if(!file_exists($this->root_path) && mkdir($this->root_path) === false)
22
+		if (!file_exists($this->root_path) && mkdir($this->root_path) === false)
23 23
 			return [];
24 24
 
25
-    $filenames = self::preg_scandir($this->root_path, $regex);// ID_SEQUENCENUMBER.ext
26
-    if(!is_null($filenames))
25
+    $filenames = self::preg_scandir($this->root_path, $regex); // ID_SEQUENCENUMBER.ext
26
+    if (!is_null($filenames))
27 27
       sort($filenames);
28 28
 
29 29
     return $filenames;
30 30
   }
31 31
 
32
-  public function filepathes($regex=null) : array
32
+  public function filepathes($regex = null) : array
33 33
   {
34 34
     $filenames = $this->filenames($regex);
35 35
     $filepathes = [];
36
-    foreach($filenames as $filename)
36
+    foreach ($filenames as $filename)
37 37
       $filepathes[] = $this->path_to($filename);
38 38
 
39 39
     return $filepathes;
@@ -41,18 +41,18 @@  discard block
 block discarded – undo
41 41
 
42 42
 
43 43
   // kontrolas ĉu la dosiero aŭ dosierujo ekzistas
44
-  public static function exists($src_path){     return file_exists($src_path);}
45
-  public static function is_file($src_path){    return is_file($src_path);}
46
-  public static function is_dir($src_path){     return is_dir($src_path);}
47
-  public static function is_link($src_path){    return is_link($src_path);}
44
+  public static function exists($src_path) {     return file_exists($src_path); }
45
+  public static function is_file($src_path) {    return is_file($src_path); }
46
+  public static function is_dir($src_path) {     return is_dir($src_path); }
47
+  public static function is_link($src_path) {    return is_link($src_path); }
48 48
 
49 49
 
50 50
   public static function resolve_symlink($path)
51 51
   {
52
-    if(is_link($path))
52
+    if (is_link($path))
53 53
     {
54 54
       $res = readlink($path);
55
-      if($res === false)
55
+      if ($res === false)
56 56
         throw new \Exception('readlink failed on '.$path);
57 57
 
58 58
       $path = $res;
@@ -62,10 +62,10 @@  discard block
 block discarded – undo
62 62
 
63 63
   public static function copy($src_path, $dst_path)
64 64
   {
65
-    if(self::exists($src_path) && self::is_file($src_path))
65
+    if (self::exists($src_path) && self::is_file($src_path))
66 66
     {
67 67
       $dst = new FilePath($dst_path);
68
-      if(self::exists($dst->dir()) && self::is_dir($dst->dir()))
68
+      if (self::exists($dst->dir()) && self::is_dir($dst->dir()))
69 69
         return copy($src_path, $dst_path); // Returns TRUE on success or FALSE on failure.
70 70
 
71 71
       // vd(__FUNCTION__.'ERR: self::exists('.$dst->dir().') && self::is_dir('.$dst->dir().')');
@@ -76,10 +76,10 @@  discard block
 block discarded – undo
76 76
 
77 77
   public static function move($src_path, $dst_path)
78 78
   {
79
-    if(self::exists($src_path) && self::is_file($src_path))
79
+    if (self::exists($src_path) && self::is_file($src_path))
80 80
     {
81 81
       $dst = new FilePath($dst_path);
82
-      if(self::exists($dst->dir()) && self::is_dir($dst->dir()))
82
+      if (self::exists($dst->dir()) && self::is_dir($dst->dir()))
83 83
       {
84 84
         return rename($src_path, $dst_path); // Returns TRUE on success or FALSE on failure.
85 85
       }
@@ -92,33 +92,33 @@  discard block
 block discarded – undo
92 92
   }
93 93
 
94 94
 
95
-  public static function make_dir($dst_path, $permission=0777, $recursive=true) : bool
95
+  public static function make_dir($dst_path, $permission = 0777, $recursive = true) : bool
96 96
   {
97 97
     return mkdir($dst_path, $permission, $recursive);
98 98
   }
99 99
 
100
-  public static function remove($src_path, $follow_link=false)
100
+  public static function remove($src_path, $follow_link = false)
101 101
   {
102 102
     $ret = false;
103
-    if(self::exists($src_path))
103
+    if (self::exists($src_path))
104 104
     {
105
-      if(self::is_link($src_path) && $follow_link === true)
105
+      if (self::is_link($src_path) && $follow_link === true)
106 106
         $ret = self::remove(readlink($src_path));
107
-      elseif(self::is_file($src_path))
107
+      elseif (self::is_file($src_path))
108 108
         $ret = unlink($src_path); // Returns TRUE on success or FALSE on failure.
109
-      else if(self::is_dir($src_path))
109
+      else if (self::is_dir($src_path))
110 110
         $ret = rmdir($src_path); // Returns TRUE on success or FALSE on failure.
111 111
     }
112 112
     return $ret;
113 113
   }
114 114
 
115
-  public static function preg_scandir($dir_path, $regex=null)
115
+  public static function preg_scandir($dir_path, $regex = null)
116 116
   {
117
-    if(!self::exists($dir_path) || !self::is_dir($dir_path))
117
+    if (!self::exists($dir_path) || !self::is_dir($dir_path))
118 118
       return null;
119 119
 
120
-    if(($filenames = scandir($dir_path, SCANDIR_SORT_ASCENDING)) !== false)
121
-      return is_null($regex)? $filenames : preg_grep($regex, $filenames);
120
+    if (($filenames = scandir($dir_path, SCANDIR_SORT_ASCENDING)) !== false)
121
+      return is_null($regex) ? $filenames : preg_grep($regex, $filenames);
122 122
 
123 123
     throw new \Exception("directory path '$dir_path' cannot be scanned");
124 124
   }
Please login to merge, or discard this patch.