Passed
Push — main ( 2c37f6...88fc45 )
by Sammy
01:19
created
File.class.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -13,9 +13,9 @@  discard block
 block discarded – undo
13 13
   // private static $modes_create_unexisting_file = ['w', 'w+', 'a', 'a+', 'c', 'c+'];
14 14
   // private static $modes_require_unexisting_file = ['x', 'x+'];
15 15
 
16
-  public function __construct($path_to_file, $mode='r')
16
+  public function __construct($path_to_file, $mode = 'r')
17 17
   {
18
-    if(!FileSystem::exists($path_to_file) && self::requires_existing_file($mode))
18
+    if (!FileSystem::exists($path_to_file) && self::requires_existing_file($mode))
19 19
       throw new \Exception('FILE_MUST_ALREADY_EXIST ('.$this->filepath().', '.$this->mode.')');
20 20
 
21 21
     $this->filepath = new FilePath($path_to_file);
@@ -25,17 +25,17 @@  discard block
 block discarded – undo
25 25
   public function open()
26 26
   {
27 27
     $this->pointer = fopen($this->filepath, $this->mode);
28
-    if($this->pointer === false)
28
+    if ($this->pointer === false)
29 29
       throw new \Exception('FILE_OPEN_FAILURE ('.$this->filepath().', '.$this->mode.')');
30 30
     return $this->pointer;
31 31
   }
32 32
 
33 33
   public function close()
34 34
   {
35
-    if(!is_resource($this->pointer))
35
+    if (!is_resource($this->pointer))
36 36
       return true;
37 37
 
38
-    if(fclose($this->pointer) === false)
38
+    if (fclose($this->pointer) === false)
39 39
       throw new \Exception('FILE_CLOSE_FAILURE ('.$this->filepath().', '.$this->mode.')');
40 40
 
41 41
     return true;
@@ -48,11 +48,11 @@  discard block
 block discarded – undo
48 48
 
49 49
   public function set_content($content)
50 50
   {
51
-    if(is_writable($this->filepath) !== true && self::requires_existing_file($this->mode))
51
+    if (is_writable($this->filepath) !== true && self::requires_existing_file($this->mode))
52 52
       throw new \Exception('FILE_IS_NOT_WRITABLE ('.$this->filepath().', '.$this->mode.')');
53 53
 
54 54
     $this->open();
55
-    if(fwrite($this->pointer, $content) === false)
55
+    if (fwrite($this->pointer, $content) === false)
56 56
       throw new \Exception('FILE_WRITE_FAILURE ('.$this->filepath().', '.$this->mode.')');
57 57
     $this->close();
58 58
   }
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
   {
72 72
     $res = $this->size_in_bytes;
73 73
 
74
-    if(is_null($res) && ($res = filesize("$this->filepath")) !== false)
74
+    if (is_null($res) && ($res = filesize("$this->filepath")) !== false)
75 75
       $this->size_in_bytes = $res;
76 76
 
77 77
     return $res;
Please login to merge, or discard this patch.
Text/TextFile.class.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
   public static function identical($filepath_1, $filepath_2, $read_length = 8192)
9 9
   {
10 10
     //** TEST FOR EXISTENCE
11
-    if(!file_exists($filepath_1) || !file_exists($filepath_2))
11
+    if (!file_exists($filepath_1) || !file_exists($filepath_2))
12 12
       throw new \Exception('file_exists false');
13 13
 
14 14
     //** TEST FOR SYMLINK
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
     $filepath_2 = self::resolve_symlink($filepath_2);
17 17
 
18 18
     //** TEST FOR IDENTICAL TYPE AND SIZE
19
-    if(filetype($filepath_1) !== filetype($filepath_2) || filesize($filepath_1) !== filesize($filepath_2))
19
+    if (filetype($filepath_1) !== filetype($filepath_2) || filesize($filepath_1) !== filesize($filepath_2))
20 20
       return false;
21 21
 
22 22
     //** TEST FOR IDENTICAL CONTENT
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
       $identical = true;
36 36
       while (!feof($filepointer_1) && !feof($filepointer_2) && $identical)
37 37
       {
38
-        if(false === ($buffer_1 = fread($filepointer_1, $read_length)) || false === ($buffer_2 = fread($filepointer_2, $read_length)))
38
+        if (false === ($buffer_1 = fread($filepointer_1, $read_length)) || false === ($buffer_2 = fread($filepointer_2, $read_length)))
39 39
         {
40 40
           throw new \Exception('FAILED fread('.$filepath_1.' or '.$filepath_2.')');
41 41
         }
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
         $identical = (0 === strcmp($buffer_1, $buffer_2));
44 44
       }
45 45
 
46
-      if($identical === true && feof($filepointer_1) !== feof($filepointer_2))
46
+      if ($identical === true && feof($filepointer_1) !== feof($filepointer_2))
47 47
         $identical = false;
48 48
 
49 49
     }
Please login to merge, or discard this patch.
Text/JSON.class.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -10,18 +10,18 @@  discard block
 block discarded – undo
10 10
     $ret = json_decode($string, $assoc, $depth, $options);
11 11
 
12 12
     $error = self::has_errors();
13
-    if($error !== false)
13
+    if ($error !== false)
14 14
       throw new \Exception("ParsingException: $error");
15 15
 
16 16
     return $ret;
17 17
   }
18 18
 
19
-  public static function from_php($var, $options= 0, $depth = 512)
19
+  public static function from_php($var, $options = 0, $depth = 512)
20 20
   {
21 21
     $ret = json_encode($var, $options, $depth);
22 22
 
23 23
     $error = self::has_errors();
24
-    if($error !== false)
24
+    if ($error !== false)
25 25
       throw new \Exception("ParsingException: $error");
26 26
 
27 27
     return $ret;
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 
30 30
   private static function has_errors()
31 31
   {
32
-    if(json_last_error() === JSON_ERROR_NONE)
32
+    if (json_last_error() === JSON_ERROR_NONE)
33 33
       return false;
34 34
 
35 35
     return json_last_error_msg();
Please login to merge, or discard this patch.
Text/INI.class.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -9,23 +9,23 @@  discard block
 block discarded – undo
9 9
   {
10 10
     $ret = '# INI Dump';
11 11
 
12
-    if(is_array(current($array))) // with sections
12
+    if (is_array(current($array))) // with sections
13 13
     {
14
-      foreach($array as $section => $data)
14
+      foreach ($array as $section => $data)
15 15
       {
16
-        $ret.= PHP_EOL.PHP_EOL.self::section($section);
17
-        foreach($data as $key => $value)
18
-          $ret.= PHP_EOL.self::line($key, $value);
16
+        $ret .= PHP_EOL.PHP_EOL.self::section($section);
17
+        foreach ($data as $key => $value)
18
+          $ret .= PHP_EOL.self::line($key, $value);
19 19
       }
20 20
     }
21 21
     else // no section
22
-      foreach($array as $key => $value)
23
-        $ret.= self::line($key, $value);
22
+      foreach ($array as $key => $value)
23
+        $ret .= self::line($key, $value);
24 24
 
25 25
     return $ret;
26 26
   }
27 27
 
28
-  public static function to_array($filepath, $with_sections=true, $mode=INI_SCANNER_RAW)
28
+  public static function to_array($filepath, $with_sections = true, $mode = INI_SCANNER_RAW)
29 29
   {
30 30
     return parse_ini_file($filepath, $with_sections, $mode);
31 31
     //https://secure.php.net/manual/en/function.parse-ini-file.php
@@ -53,6 +53,6 @@  discard block
 block discarded – undo
53 53
 
54 54
   private static function format_key($key)
55 55
   {
56
-    return str_replace(' ', '_',$key);
56
+    return str_replace(' ', '_', $key);
57 57
   }
58 58
 }
Please login to merge, or discard this patch.
FilePath.class.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
     $this->filepath = $filepath;
18 18
   }
19 19
 
20
-  public function __toString(){ return ''.$this->filepath;}
20
+  public function __toString() { return ''.$this->filepath; }
21 21
 
22 22
   public function dir() : string
23 23
   {
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 
37 37
   private function parse()
38 38
   {
39
-    if($this->already_parsed === false)
39
+    if ($this->already_parsed === false)
40 40
     {
41 41
       $res = pathinfo($this->filepath);
42 42
 
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
       $this->file = $res['basename'];
45 45
       $this->file_extension = $res['extension'];
46 46
 
47
-      $this->already_parsed=true;
47
+      $this->already_parsed = true;
48 48
     }
49 49
     return $this;
50 50
   }
Please login to merge, or discard this patch.
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.