Passed
Push — main ( 801b6a...3683b4 )
by Sammy
01:38
created
tests/FileSystemTest.php 1 patch
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 
13 13
     protected function setUp(): void
14 14
     {
15
-        $this->testRootPath = sys_get_temp_dir() . '/hexmakina_localfs_test';
15
+        $this->testRootPath = sys_get_temp_dir().'/hexmakina_localfs_test';
16 16
         if (!file_exists($this->testRootPath)) {
17 17
             mkdir($this->testRootPath);
18 18
         }
@@ -30,10 +30,10 @@  discard block
 block discarded – undo
30 30
             $objects = scandir($dir);
31 31
             foreach ($objects as $object) {
32 32
                 if ($object != "." && $object != "..") {
33
-                    if (is_dir($dir . "/" . $object)) {
34
-                        $this->removeDirectory($dir . "/" . $object);
33
+                    if (is_dir($dir."/".$object)) {
34
+                        $this->removeDirectory($dir."/".$object);
35 35
                     } else {
36
-                        unlink($dir . "/" . $object);
36
+                        unlink($dir."/".$object);
37 37
                     }
38 38
                 }
39 39
             }
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
     $fileSystem = new FileSystem($testRootPath);
57 57
 
58 58
     $relativePath = 'subdir/file.txt';
59
-    $expectedPath = $testRootPath . '/' . $relativePath;
59
+    $expectedPath = $testRootPath.'/'.$relativePath;
60 60
 
61 61
     $result = $fileSystem->absolutePathFor($relativePath);
62 62
 
@@ -77,8 +77,8 @@  discard block
 block discarded – undo
77 77
 
78 78
 public function testCopyNonExistentSourceFile()
79 79
 {
80
-    $nonExistentSourcePath = $this->testRootPath . '/non_existent_file.txt';
81
-    $destinationPath = $this->testRootPath . '/destination.txt';
80
+    $nonExistentSourcePath = $this->testRootPath.'/non_existent_file.txt';
81
+    $destinationPath = $this->testRootPath.'/destination.txt';
82 82
 
83 83
     $result = FileSystem::copy($nonExistentSourcePath, $destinationPath);
84 84
 
@@ -88,10 +88,10 @@  discard block
 block discarded – undo
88 88
 
89 89
 public function testResolveSymlink()
90 90
 {
91
-    $tempDir = sys_get_temp_dir() . '/symlink_test';
91
+    $tempDir = sys_get_temp_dir().'/symlink_test';
92 92
     mkdir($tempDir);
93
-    $targetFile = $tempDir . '/target.txt';
94
-    $symlinkFile = $tempDir . '/symlink.txt';
93
+    $targetFile = $tempDir.'/target.txt';
94
+    $symlinkFile = $tempDir.'/symlink.txt';
95 95
 
96 96
     file_put_contents($targetFile, 'Test content');
97 97
     symlink($targetFile, $symlinkFile);
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 
108 108
 public function testEnsureWritablePathCreatesDirectories()
109 109
 {
110
-    $nonExistentPath = $this->testRootPath . '/new/nested/directory';
110
+    $nonExistentPath = $this->testRootPath.'/new/nested/directory';
111 111
     $this->assertFalse(is_dir($nonExistentPath));
112 112
 
113 113
     $result = $this->fileSystem->ensureWritablePath($nonExistentPath);
@@ -129,12 +129,12 @@  discard block
 block discarded – undo
129 129
 
130 130
 public function testDirectoriesListsOnlyDirectories()
131 131
 {
132
-    $testDir = $this->testRootPath . '/test_directories';
132
+    $testDir = $this->testRootPath.'/test_directories';
133 133
     mkdir($testDir);
134
-    mkdir($testDir . '/dir1');
135
-    mkdir($testDir . '/dir2');
136
-    touch($testDir . '/file1.txt');
137
-    touch($testDir . '/file2.txt');
134
+    mkdir($testDir.'/dir1');
135
+    mkdir($testDir.'/dir2');
136
+    touch($testDir.'/file1.txt');
137
+    touch($testDir.'/file2.txt');
138 138
 
139 139
     $result = $this->fileSystem->directories('test_directories');
140 140
 
@@ -147,13 +147,13 @@  discard block
 block discarded – undo
147 147
 
148 148
 public function testFilesListsOnlyFilesInSpecifiedDirectory()
149 149
 {
150
-    $testDir = $this->testRootPath . '/test_files';
150
+    $testDir = $this->testRootPath.'/test_files';
151 151
     mkdir($testDir);
152 152
     
153 153
     // Create test files and directories
154
-    touch($testDir . '/file1.txt');
155
-    touch($testDir . '/file2.txt');
156
-    mkdir($testDir . '/subdir');
154
+    touch($testDir.'/file1.txt');
155
+    touch($testDir.'/file2.txt');
156
+    mkdir($testDir.'/subdir');
157 157
     
158 158
     $fileSystem = new FileSystem($this->testRootPath);
159 159
     $files = $fileSystem->files('test_files');
@@ -164,9 +164,9 @@  discard block
 block discarded – undo
164 164
     $this->assertNotContains('subdir', $files);
165 165
     
166 166
     // Clean up
167
-    unlink($testDir . '/file1.txt');
168
-    unlink($testDir . '/file2.txt');
169
-    rmdir($testDir . '/subdir');
167
+    unlink($testDir.'/file1.txt');
168
+    unlink($testDir.'/file2.txt');
169
+    rmdir($testDir.'/subdir');
170 170
     rmdir($testDir);
171 171
 }
172 172
 }
Please login to merge, or discard this patch.
src/FileSystem.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -94,8 +94,8 @@  discard block
 block discarded – undo
94 94
     {
95 95
         $absolutePath = $this->absolutePathFor($relativePath);
96 96
         // Filter the list of files to include only files (not directories).
97
-        $files = array_filter($this->list($relativePath), function ($filename) use ($absolutePath) {
98
-            return is_file($absolutePath . DIRECTORY_SEPARATOR . $filename);
97
+        $files = array_filter($this->list($relativePath), function($filename) use ($absolutePath) {
98
+            return is_file($absolutePath.DIRECTORY_SEPARATOR.$filename);
99 99
         });
100 100
 
101 101
         return $files;
@@ -112,8 +112,8 @@  discard block
 block discarded – undo
112 112
         $absolutePath = $this->absolutePathFor($relativePath);
113 113
 
114 114
         // Filter the list of files to include only files (not directories).
115
-        $files = array_filter($this->list($relativePath), function ($filename) use ($absolutePath) {
116
-            return is_dir($absolutePath . DIRECTORY_SEPARATOR . $filename);
115
+        $files = array_filter($this->list($relativePath), function($filename) use ($absolutePath) {
116
+            return is_dir($absolutePath.DIRECTORY_SEPARATOR.$filename);
117 117
         });
118 118
 
119 119
         return $files;
@@ -127,19 +127,19 @@  discard block
 block discarded – undo
127 127
      * @return bool True if the path is writable, false otherwise.
128 128
      */
129 129
 
130
-    public function ensureWritablePath(string $absoluteDirectoryPath, string $filename=null): bool
130
+    public function ensureWritablePath(string $absoluteDirectoryPath, string $filename = null): bool
131 131
     {
132 132
         if (strpos($absoluteDirectoryPath, $this->root()) !== 0) {
133 133
             throw new \InvalidArgumentException('PATH_NOT_INSIDE_ROOT_PATH');
134 134
         }
135 135
 
136
-        $relativeDirectoryPath = substr($absoluteDirectoryPath, strlen($this->root()) + 1);
136
+        $relativeDirectoryPath = substr($absoluteDirectoryPath, strlen($this->root())+1);
137 137
         $pathParts = explode('/', $relativeDirectoryPath);
138 138
         
139 139
 
140 140
         $targetDir = $this->root();
141 141
         foreach ($pathParts as $i => $part) {
142
-            $targetDir .= '/' . $part;
142
+            $targetDir .= '/'.$part;
143 143
 
144 144
             // Create the folder if it doesn't exist
145 145
             if (!file_exists($targetDir) && mkdir($targetDir, 0755, true) === false) {
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -27,8 +27,9 @@
 block discarded – undo
27 27
     function __construct(string $rootPath)
28 28
     {
29 29
         $rootPath = realpath($rootPath);
30
-        if (!$rootPath)
31
-            throw new \InvalidArgumentException('INVALID_ROOT_PATH');
30
+        if (!$rootPath) {
31
+                    throw new \InvalidArgumentException('INVALID_ROOT_PATH');
32
+        }
32 33
 
33 34
         $this->rootPath = $rootPath;
34 35
     }
Please login to merge, or discard this patch.
src/File.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -80,9 +80,9 @@
 block discarded – undo
80 80
     }
81 81
 
82 82
    
83
-    public function getMIMEType($fast=true): string
83
+    public function getMIMEType($fast = true): string
84 84
     {
85
-        if($fast === true || extension_loaded('fileinfo') === false){
85
+        if ($fast === true || extension_loaded('fileinfo') === false) {
86 86
             return mime_content_type($this->path());
87 87
         }
88 88
 
Please login to merge, or discard this patch.
src/FilePath.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@
 block discarded – undo
19 19
 
20 20
     public function __toString()
21 21
     {
22
-        return '' . $this->filepath;
22
+        return ''.$this->filepath;
23 23
     }
24 24
 
25 25
     public function dir(): string
Please login to merge, or discard this patch.
src/Text/INI.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -11,9 +11,9 @@  discard block
 block discarded – undo
11 11
 
12 12
         if (is_array(current($array))) { // with sections
13 13
             foreach ($array as $section => $data) {
14
-                $ret .= PHP_EOL . PHP_EOL . self::section($section);
14
+                $ret .= PHP_EOL.PHP_EOL.self::section($section);
15 15
                 foreach ($data as $key => $value) {
16
-                    $ret .= PHP_EOL . self::line($key, $value);
16
+                    $ret .= PHP_EOL.self::line($key, $value);
17 17
                 }
18 18
             }
19 19
         } else { // no section
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
     {
30 30
         // https://secure.php.net/manual/en/function.parse-ini-file.php
31 31
         $ret = parse_ini_file($filepath, $with_sections, $mode);
32
-        if($ret === false)
32
+        if ($ret === false)
33 33
             return null;
34 34
 
35 35
         return $ret;
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -29,8 +29,9 @@
 block discarded – undo
29 29
     {
30 30
         // https://secure.php.net/manual/en/function.parse-ini-file.php
31 31
         $ret = parse_ini_file($filepath, $with_sections, $mode);
32
-        if($ret === false)
33
-            return null;
32
+        if($ret === false) {
33
+                    return null;
34
+        }
34 35
 
35 36
         return $ret;
36 37
     }
Please login to merge, or discard this patch.
src/Text/TextFile.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -67,7 +67,7 @@
 block discarded – undo
67 67
     public function __toString()
68 68
     {
69 69
         $ret = file_get_contents($this->path());
70
-        if($ret === false)
70
+        if ($ret === false)
71 71
             $ret = $this->path();
72 72
 
73 73
         return $ret;
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -67,8 +67,9 @@
 block discarded – undo
67 67
     public function __toString()
68 68
     {
69 69
         $ret = file_get_contents($this->path());
70
-        if($ret === false)
71
-            $ret = $this->path();
70
+        if($ret === false) {
71
+                    $ret = $this->path();
72
+        }
72 73
 
73 74
         return $ret;
74 75
     }
Please login to merge, or discard this patch.
src/Text/JSON.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -41,6 +41,6 @@
 block discarded – undo
41 41
         if (json_last_error() === JSON_ERROR_NONE) {
42 42
             return false;
43 43
         }
44
-        throw new \Exception('ParsingException: '.json_last_error_msg());;
44
+        throw new \Exception('ParsingException: '.json_last_error_msg()); ;
45 45
     }
46 46
 }
Please login to merge, or discard this patch.