@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | public function testEnsureDirectory(): void |
| 33 | 33 | { |
| 34 | 34 | $files = new Files(); |
| 35 | - $directory = self::FIXTURE_DIRECTORY . 'directory/'; |
|
| 35 | + $directory = self::FIXTURE_DIRECTORY.'directory/'; |
|
| 36 | 36 | |
| 37 | 37 | $this->assertFalse($files->exists($directory)); |
| 38 | 38 | $this->assertFalse($files->isDirectory($directory)); |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | public function testEnsureExistedDirectory(): void |
| 47 | 47 | { |
| 48 | 48 | $files = new Files(); |
| 49 | - $directory = self::FIXTURE_DIRECTORY . 'directory/'; |
|
| 49 | + $directory = self::FIXTURE_DIRECTORY.'directory/'; |
|
| 50 | 50 | |
| 51 | 51 | $this->assertFalse($files->exists($directory)); |
| 52 | 52 | $this->assertFalse($files->isDirectory($directory)); |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | public function testEnsureNestedDirectory(): void |
| 66 | 66 | { |
| 67 | 67 | $files = new Files(); |
| 68 | - $directory = self::FIXTURE_DIRECTORY . 'directory/sub/other'; |
|
| 68 | + $directory = self::FIXTURE_DIRECTORY.'directory/sub/other'; |
|
| 69 | 69 | |
| 70 | 70 | $this->assertFalse($files->exists($directory)); |
| 71 | 71 | $this->assertFalse($files->isDirectory($directory)); |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | public function testEnsureNestedDirectoryNoRecursivePermissions(): void |
| 80 | 80 | { |
| 81 | 81 | $files = new Files(); |
| 82 | - $directory = self::FIXTURE_DIRECTORY . 'directory/sub/other'; |
|
| 82 | + $directory = self::FIXTURE_DIRECTORY.'directory/sub/other'; |
|
| 83 | 83 | |
| 84 | 84 | $this->assertFalse($files->exists($directory)); |
| 85 | 85 | $this->assertFalse($files->isDirectory($directory)); |
@@ -93,14 +93,14 @@ discard block |
||
| 93 | 93 | public function testEnsureExistedNestedDirectory(): void |
| 94 | 94 | { |
| 95 | 95 | $files = new Files(); |
| 96 | - $directory = self::FIXTURE_DIRECTORY . 'directory/sub/other'; |
|
| 96 | + $directory = self::FIXTURE_DIRECTORY.'directory/sub/other'; |
|
| 97 | 97 | |
| 98 | 98 | $this->assertFalse($files->exists($directory)); |
| 99 | 99 | $this->assertFalse($files->isDirectory($directory)); |
| 100 | 100 | |
| 101 | - mkdir(self::FIXTURE_DIRECTORY . 'directory'); |
|
| 102 | - mkdir(self::FIXTURE_DIRECTORY . 'directory/sub'); |
|
| 103 | - mkdir(self::FIXTURE_DIRECTORY . 'directory/sub/other'); |
|
| 101 | + mkdir(self::FIXTURE_DIRECTORY.'directory'); |
|
| 102 | + mkdir(self::FIXTURE_DIRECTORY.'directory/sub'); |
|
| 103 | + mkdir(self::FIXTURE_DIRECTORY.'directory/sub/other'); |
|
| 104 | 104 | |
| 105 | 105 | $this->assertTrue($files->exists($directory)); |
| 106 | 106 | $this->assertTrue($files->isDirectory($directory)); |
@@ -114,13 +114,13 @@ discard block |
||
| 114 | 114 | public function testDeleteDirectoryContent(): void |
| 115 | 115 | { |
| 116 | 116 | $files = new Files(); |
| 117 | - $baseDirectory = self::FIXTURE_DIRECTORY . 'directory/'; |
|
| 118 | - $directory = $baseDirectory . 'sub/other'; |
|
| 117 | + $baseDirectory = self::FIXTURE_DIRECTORY.'directory/'; |
|
| 118 | + $directory = $baseDirectory.'sub/other'; |
|
| 119 | 119 | |
| 120 | 120 | $filenames = [ |
| 121 | - $baseDirectory . 'test.file', |
|
| 122 | - $directory . 'other.file', |
|
| 123 | - $directory . '.sample', |
|
| 121 | + $baseDirectory.'test.file', |
|
| 122 | + $directory.'other.file', |
|
| 123 | + $directory.'.sample', |
|
| 124 | 124 | ]; |
| 125 | 125 | |
| 126 | 126 | $this->assertFalse($files->exists($baseDirectory)); |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | $this->assertTrue($files->exists($directory)); |
| 138 | 138 | $this->assertTrue($files->isDirectory($directory)); |
| 139 | 139 | |
| 140 | - foreach ($filenames as $filename) { |
|
| 140 | + foreach ($filenames as $filename){ |
|
| 141 | 141 | $this->assertFalse($files->exists($filename)); |
| 142 | 142 | $files->write($filename, 'random-data'); |
| 143 | 143 | $this->assertTrue($files->exists($filename)); |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | $this->assertFalse($files->exists($directory)); |
| 152 | 152 | $this->assertFalse($files->isDirectory($directory)); |
| 153 | 153 | |
| 154 | - foreach ($filenames as $filename) { |
|
| 154 | + foreach ($filenames as $filename){ |
|
| 155 | 155 | $this->assertFalse($files->exists($filename)); |
| 156 | 156 | } |
| 157 | 157 | } |
@@ -159,13 +159,13 @@ discard block |
||
| 159 | 159 | public function testDeleteDirectory(): void |
| 160 | 160 | { |
| 161 | 161 | $files = new Files(); |
| 162 | - $baseDirectory = self::FIXTURE_DIRECTORY . 'directory/'; |
|
| 163 | - $directory = $baseDirectory . 'sub/other'; |
|
| 162 | + $baseDirectory = self::FIXTURE_DIRECTORY.'directory/'; |
|
| 163 | + $directory = $baseDirectory.'sub/other'; |
|
| 164 | 164 | |
| 165 | 165 | $filenames = [ |
| 166 | - $baseDirectory . 'test.file', |
|
| 167 | - $directory . 'other.file', |
|
| 168 | - $directory . '.sample', |
|
| 166 | + $baseDirectory.'test.file', |
|
| 167 | + $directory.'other.file', |
|
| 168 | + $directory.'.sample', |
|
| 169 | 169 | ]; |
| 170 | 170 | |
| 171 | 171 | $this->assertFalse($files->exists($baseDirectory)); |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | $this->assertTrue($files->exists($directory)); |
| 183 | 183 | $this->assertTrue($files->isDirectory($directory)); |
| 184 | 184 | |
| 185 | - foreach ($filenames as $filename) { |
|
| 185 | + foreach ($filenames as $filename){ |
|
| 186 | 186 | $this->assertFalse($files->exists($filename)); |
| 187 | 187 | $files->write($filename, 'random-data'); |
| 188 | 188 | $this->assertTrue($files->exists($filename)); |
@@ -196,7 +196,7 @@ discard block |
||
| 196 | 196 | $this->assertFalse($files->exists($directory)); |
| 197 | 197 | $this->assertFalse($files->isDirectory($directory)); |
| 198 | 198 | |
| 199 | - foreach ($filenames as $filename) { |
|
| 199 | + foreach ($filenames as $filename){ |
|
| 200 | 200 | $this->assertFalse($files->exists($filename)); |
| 201 | 201 | } |
| 202 | 202 | } |
@@ -207,8 +207,8 @@ discard block |
||
| 207 | 207 | |
| 208 | 208 | $files = new Files(); |
| 209 | 209 | |
| 210 | - $files->write(self::FIXTURE_DIRECTORY . 'test', 'data'); |
|
| 211 | - $files->deleteDirectory(self::FIXTURE_DIRECTORY . 'test'); |
|
| 210 | + $files->write(self::FIXTURE_DIRECTORY.'test', 'data'); |
|
| 211 | + $files->deleteDirectory(self::FIXTURE_DIRECTORY.'test'); |
|
| 212 | 212 | } |
| 213 | 213 | |
| 214 | 214 | public function testGetFiles(): void |
@@ -137,7 +137,8 @@ discard block |
||
| 137 | 137 | $this->assertTrue($files->exists($directory)); |
| 138 | 138 | $this->assertTrue($files->isDirectory($directory)); |
| 139 | 139 | |
| 140 | - foreach ($filenames as $filename) { |
|
| 140 | + foreach ($filenames as $filename) |
|
| 141 | + { |
|
| 141 | 142 | $this->assertFalse($files->exists($filename)); |
| 142 | 143 | $files->write($filename, 'random-data'); |
| 143 | 144 | $this->assertTrue($files->exists($filename)); |
@@ -151,7 +152,8 @@ discard block |
||
| 151 | 152 | $this->assertFalse($files->exists($directory)); |
| 152 | 153 | $this->assertFalse($files->isDirectory($directory)); |
| 153 | 154 | |
| 154 | - foreach ($filenames as $filename) { |
|
| 155 | + foreach ($filenames as $filename) |
|
| 156 | + { |
|
| 155 | 157 | $this->assertFalse($files->exists($filename)); |
| 156 | 158 | } |
| 157 | 159 | } |
@@ -182,7 +184,8 @@ discard block |
||
| 182 | 184 | $this->assertTrue($files->exists($directory)); |
| 183 | 185 | $this->assertTrue($files->isDirectory($directory)); |
| 184 | 186 | |
| 185 | - foreach ($filenames as $filename) { |
|
| 187 | + foreach ($filenames as $filename) |
|
| 188 | + { |
|
| 186 | 189 | $this->assertFalse($files->exists($filename)); |
| 187 | 190 | $files->write($filename, 'random-data'); |
| 188 | 191 | $this->assertTrue($files->exists($filename)); |
@@ -196,7 +199,8 @@ discard block |
||
| 196 | 199 | $this->assertFalse($files->exists($directory)); |
| 197 | 200 | $this->assertFalse($files->isDirectory($directory)); |
| 198 | 201 | |
| 199 | - foreach ($filenames as $filename) { |
|
| 202 | + foreach ($filenames as $filename) |
|
| 203 | + { |
|
| 200 | 204 | $this->assertFalse($files->exists($filename)); |
| 201 | 205 | } |
| 202 | 206 | } |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | { |
| 35 | 35 | $files = new Files(); |
| 36 | 36 | |
| 37 | - $filename = self::FIXTURE_DIRECTORY . '/test.txt'; |
|
| 37 | + $filename = self::FIXTURE_DIRECTORY.'/test.txt'; |
|
| 38 | 38 | $this->assertFalse($files->exists($filename)); |
| 39 | 39 | |
| 40 | 40 | $files->write($filename, 'some-data'); |
@@ -47,8 +47,8 @@ discard block |
||
| 47 | 47 | { |
| 48 | 48 | $files = new Files(); |
| 49 | 49 | |
| 50 | - $directory = self::FIXTURE_DIRECTORY . '/directory/abc/'; |
|
| 51 | - $filename = $directory . 'test.txt'; |
|
| 50 | + $directory = self::FIXTURE_DIRECTORY.'/directory/abc/'; |
|
| 51 | + $filename = $directory.'test.txt'; |
|
| 52 | 52 | |
| 53 | 53 | $this->assertFalse($files->exists($directory)); |
| 54 | 54 | $this->assertFalse($files->exists($filename)); |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | { |
| 67 | 67 | $files = new Files(); |
| 68 | 68 | |
| 69 | - $filename = self::FIXTURE_DIRECTORY . '/test.txt'; |
|
| 69 | + $filename = self::FIXTURE_DIRECTORY.'/test.txt'; |
|
| 70 | 70 | $this->assertFalse($files->exists($filename)); |
| 71 | 71 | |
| 72 | 72 | $files->write($filename, 'some-data'); |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | |
| 83 | 83 | $files = new Files(); |
| 84 | 84 | |
| 85 | - $filename = self::FIXTURE_DIRECTORY . '/test.txt'; |
|
| 85 | + $filename = self::FIXTURE_DIRECTORY.'/test.txt'; |
|
| 86 | 86 | $this->assertFalse($files->exists($filename)); |
| 87 | 87 | |
| 88 | 88 | $files->read($filename); |
@@ -101,14 +101,14 @@ discard block |
||
| 101 | 101 | $this->expectException(FileNotFoundException::class); |
| 102 | 102 | |
| 103 | 103 | $files = new Files(); |
| 104 | - $files->getPermissions(self::FIXTURE_DIRECTORY . '/missing'); |
|
| 104 | + $files->getPermissions(self::FIXTURE_DIRECTORY.'/missing'); |
|
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | public function testAppend(): void |
| 108 | 108 | { |
| 109 | 109 | $files = new Files(); |
| 110 | 110 | |
| 111 | - $filename = self::FIXTURE_DIRECTORY . '/test.txt'; |
|
| 111 | + $filename = self::FIXTURE_DIRECTORY.'/test.txt'; |
|
| 112 | 112 | $this->assertFalse($files->exists($filename)); |
| 113 | 113 | |
| 114 | 114 | $files->append($filename, 'some-data'); |
@@ -124,8 +124,8 @@ discard block |
||
| 124 | 124 | { |
| 125 | 125 | $files = new Files(); |
| 126 | 126 | |
| 127 | - $directory = self::FIXTURE_DIRECTORY . '/directory/abc/'; |
|
| 128 | - $filename = $directory . 'test.txt'; |
|
| 127 | + $directory = self::FIXTURE_DIRECTORY.'/directory/abc/'; |
|
| 128 | + $filename = $directory.'test.txt'; |
|
| 129 | 129 | |
| 130 | 130 | $this->assertFalse($files->exists($directory)); |
| 131 | 131 | $this->assertFalse($files->exists($filename)); |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | { |
| 147 | 147 | $files = new Files(); |
| 148 | 148 | |
| 149 | - $filename = self::FIXTURE_DIRECTORY . '/test.txt'; |
|
| 149 | + $filename = self::FIXTURE_DIRECTORY.'/test.txt'; |
|
| 150 | 150 | |
| 151 | 151 | $this->assertFalse($files->exists($filename)); |
| 152 | 152 | $files->touch($filename); |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | public function testDelete(): void |
| 157 | 157 | { |
| 158 | 158 | $files = new Files(); |
| 159 | - $filename = self::FIXTURE_DIRECTORY . '/test.txt'; |
|
| 159 | + $filename = self::FIXTURE_DIRECTORY.'/test.txt'; |
|
| 160 | 160 | |
| 161 | 161 | $this->assertFalse($files->exists($filename)); |
| 162 | 162 | |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | public function testDeleteMissingFile(): void |
| 171 | 171 | { |
| 172 | 172 | $files = new Files(); |
| 173 | - $filename = self::FIXTURE_DIRECTORY . '/test.txt'; |
|
| 173 | + $filename = self::FIXTURE_DIRECTORY.'/test.txt'; |
|
| 174 | 174 | |
| 175 | 175 | $this->assertFalse($files->exists($filename)); |
| 176 | 176 | $files->delete($filename); |
@@ -179,8 +179,8 @@ discard block |
||
| 179 | 179 | public function testCopy(): void |
| 180 | 180 | { |
| 181 | 181 | $files = new Files(); |
| 182 | - $filename = self::FIXTURE_DIRECTORY . '/test.txt'; |
|
| 183 | - $destination = self::FIXTURE_DIRECTORY . '/new.txt'; |
|
| 182 | + $filename = self::FIXTURE_DIRECTORY.'/test.txt'; |
|
| 183 | + $destination = self::FIXTURE_DIRECTORY.'/new.txt'; |
|
| 184 | 184 | |
| 185 | 185 | $this->assertFalse($files->exists($filename)); |
| 186 | 186 | $files->write($filename, 'some-data'); |
@@ -203,8 +203,8 @@ discard block |
||
| 203 | 203 | $this->expectException(FileNotFoundException::class); |
| 204 | 204 | |
| 205 | 205 | $files = new Files(); |
| 206 | - $filename = self::FIXTURE_DIRECTORY . '/test.txt'; |
|
| 207 | - $destination = self::FIXTURE_DIRECTORY . '/new.txt'; |
|
| 206 | + $filename = self::FIXTURE_DIRECTORY.'/test.txt'; |
|
| 207 | + $destination = self::FIXTURE_DIRECTORY.'/new.txt'; |
|
| 208 | 208 | |
| 209 | 209 | $this->assertFalse($files->exists($filename)); |
| 210 | 210 | $files->copy($filename, $destination); |
@@ -213,8 +213,8 @@ discard block |
||
| 213 | 213 | public function testMove(): void |
| 214 | 214 | { |
| 215 | 215 | $files = new Files(); |
| 216 | - $filename = self::FIXTURE_DIRECTORY . '/test.txt'; |
|
| 217 | - $destination = self::FIXTURE_DIRECTORY . '/new.txt'; |
|
| 216 | + $filename = self::FIXTURE_DIRECTORY.'/test.txt'; |
|
| 217 | + $destination = self::FIXTURE_DIRECTORY.'/new.txt'; |
|
| 218 | 218 | |
| 219 | 219 | $this->assertFalse($files->exists($filename)); |
| 220 | 220 | $files->write($filename, 'some-data'); |
@@ -237,8 +237,8 @@ discard block |
||
| 237 | 237 | $this->expectException(FileNotFoundException::class); |
| 238 | 238 | |
| 239 | 239 | $files = new Files(); |
| 240 | - $filename = self::FIXTURE_DIRECTORY . '/test.txt'; |
|
| 241 | - $destination = self::FIXTURE_DIRECTORY . '/new.txt'; |
|
| 240 | + $filename = self::FIXTURE_DIRECTORY.'/test.txt'; |
|
| 241 | + $destination = self::FIXTURE_DIRECTORY.'/new.txt'; |
|
| 242 | 242 | |
| 243 | 243 | $this->assertFalse($files->exists($filename)); |
| 244 | 244 | $files->move($filename, $destination); |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | public function testTime(): void |
| 33 | 33 | { |
| 34 | 34 | $files = new Files(); |
| 35 | - $filename = self::FIXTURE_DIRECTORY . '/test.txt'; |
|
| 35 | + $filename = self::FIXTURE_DIRECTORY.'/test.txt'; |
|
| 36 | 36 | |
| 37 | 37 | $files->write($filename, 'data', FilesInterface::READONLY); |
| 38 | 38 | $this->assertEquals(filemtime($filename), $files->time($filename)); |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | $this->expectException(FileNotFoundException::class); |
| 45 | 45 | |
| 46 | 46 | $files = new Files(); |
| 47 | - $filename = self::FIXTURE_DIRECTORY . '/test.txt'; |
|
| 47 | + $filename = self::FIXTURE_DIRECTORY.'/test.txt'; |
|
| 48 | 48 | |
| 49 | 49 | $files->time($filename); |
| 50 | 50 | } |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | public function testMD5(): void |
| 53 | 53 | { |
| 54 | 54 | $files = new Files(); |
| 55 | - $filename = self::FIXTURE_DIRECTORY . '/test.txt'; |
|
| 55 | + $filename = self::FIXTURE_DIRECTORY.'/test.txt'; |
|
| 56 | 56 | |
| 57 | 57 | $files->write($filename, 'data'); |
| 58 | 58 | $this->assertEquals(md5_file($filename), $files->md5($filename)); |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | $this->expectException(FileNotFoundException::class); |
| 66 | 66 | |
| 67 | 67 | $files = new Files(); |
| 68 | - $filename = self::FIXTURE_DIRECTORY . '/test.txt'; |
|
| 68 | + $filename = self::FIXTURE_DIRECTORY.'/test.txt'; |
|
| 69 | 69 | |
| 70 | 70 | $files->md5($filename); |
| 71 | 71 | } |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | public function testExists(): void |
| 83 | 83 | { |
| 84 | 84 | $files = new Files(); |
| 85 | - $filename = self::FIXTURE_DIRECTORY . '/test.txt'; |
|
| 85 | + $filename = self::FIXTURE_DIRECTORY.'/test.txt'; |
|
| 86 | 86 | |
| 87 | 87 | $this->assertFalse($files->exists($filename)); |
| 88 | 88 | $this->assertSame(file_exists($filename), $files->exists($filename)); |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | public function testSize(): void |
| 96 | 96 | { |
| 97 | 97 | $files = new Files(); |
| 98 | - $filename = self::FIXTURE_DIRECTORY . '/test.txt'; |
|
| 98 | + $filename = self::FIXTURE_DIRECTORY.'/test.txt'; |
|
| 99 | 99 | |
| 100 | 100 | $this->assertFalse($files->exists($filename)); |
| 101 | 101 | $files->write($filename, 'some-data-string'); |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | $this->expectException(FileNotFoundException::class); |
| 111 | 111 | |
| 112 | 112 | $files = new Files(); |
| 113 | - $filename = self::FIXTURE_DIRECTORY . '/test.txt'; |
|
| 113 | + $filename = self::FIXTURE_DIRECTORY.'/test.txt'; |
|
| 114 | 114 | |
| 115 | 115 | $this->assertFalse($files->exists($filename)); |
| 116 | 116 | $files->size($filename); |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | public function testLocalUri(): void |
| 120 | 120 | { |
| 121 | 121 | $files = new Files(); |
| 122 | - $filename = self::FIXTURE_DIRECTORY . '/test.txt'; |
|
| 122 | + $filename = self::FIXTURE_DIRECTORY.'/test.txt'; |
|
| 123 | 123 | |
| 124 | 124 | $this->assertFalse($files->exists($filename)); |
| 125 | 125 | $files->write($filename, 'data'); |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | public function testIsFile(): void |
| 130 | 130 | { |
| 131 | 131 | $files = new Files(); |
| 132 | - $filename = self::FIXTURE_DIRECTORY . '/test.txt'; |
|
| 132 | + $filename = self::FIXTURE_DIRECTORY.'/test.txt'; |
|
| 133 | 133 | |
| 134 | 134 | $this->assertFalse($files->exists($filename)); |
| 135 | 135 | $files->write($filename, 'data'); |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | public function testIsMissingFile(): void |
| 146 | 146 | { |
| 147 | 147 | $files = new Files(); |
| 148 | - $filename = self::FIXTURE_DIRECTORY . '/test.txt'; |
|
| 148 | + $filename = self::FIXTURE_DIRECTORY.'/test.txt'; |
|
| 149 | 149 | |
| 150 | 150 | $this->assertFalse($files->exists($filename)); |
| 151 | 151 | |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | public function testIsDirectory(): void |
| 160 | 160 | { |
| 161 | 161 | $files = new Files(); |
| 162 | - $directory = self::FIXTURE_DIRECTORY . '/directory/'; |
|
| 162 | + $directory = self::FIXTURE_DIRECTORY.'/directory/'; |
|
| 163 | 163 | |
| 164 | 164 | $this->assertFalse($files->exists($directory)); |
| 165 | 165 | $files->ensureDirectory($directory); |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | public function testIsMissingDirectory(): void |
| 176 | 176 | { |
| 177 | 177 | $files = new Files(); |
| 178 | - $directory = self::FIXTURE_DIRECTORY . '/directory/'; |
|
| 178 | + $directory = self::FIXTURE_DIRECTORY.'/directory/'; |
|
| 179 | 179 | |
| 180 | 180 | $this->assertFalse($files->exists($directory)); |
| 181 | 181 | |
@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | public function testIsDirectoryNoSlash(): void |
| 190 | 190 | { |
| 191 | 191 | $files = new Files(); |
| 192 | - $directory = self::FIXTURE_DIRECTORY . '/directory'; |
|
| 192 | + $directory = self::FIXTURE_DIRECTORY.'/directory'; |
|
| 193 | 193 | |
| 194 | 194 | $this->assertFalse($files->exists($directory)); |
| 195 | 195 | $files->ensureDirectory($directory); |
@@ -18,5 +18,5 @@ |
||
| 18 | 18 | /** |
| 19 | 19 | * @var string |
| 20 | 20 | */ |
| 21 | - protected const FIXTURE_DIRECTORY = __DIR__ . '/fixtures/'; |
|
| 21 | + protected const FIXTURE_DIRECTORY = __DIR__.'/fixtures/'; |
|
| 22 | 22 | } |
@@ -61,7 +61,7 @@ |
||
| 61 | 61 | $this->assertNotEquals('test string', $encrypted); |
| 62 | 62 | $this->assertEquals('test string', $encrypter->decrypt($encrypted)); |
| 63 | 63 | |
| 64 | - $encrypter->decrypt('badData.' . $encrypted); |
|
| 64 | + $encrypter->decrypt('badData.'.$encrypted); |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | public function testBadKey(): void |
@@ -37,9 +37,9 @@ discard block |
||
| 37 | 37 | */ |
| 38 | 38 | public function __construct(string $key) |
| 39 | 39 | { |
| 40 | - try { |
|
| 40 | + try{ |
|
| 41 | 41 | $this->key = Key::loadFromAsciiSafeString($key); |
| 42 | - } catch (CryptoException $e) { |
|
| 42 | + }catch (CryptoException $e){ |
|
| 43 | 43 | throw new EncrypterException($e->getMessage(), $e->getCode(), $e); |
| 44 | 44 | } |
| 45 | 45 | } |
@@ -50,9 +50,9 @@ discard block |
||
| 50 | 50 | public function withKey(string $key): EncrypterInterface |
| 51 | 51 | { |
| 52 | 52 | $encrypter = clone $this; |
| 53 | - try { |
|
| 53 | + try{ |
|
| 54 | 54 | $encrypter->key = Key::loadFromAsciiSafeString($key); |
| 55 | - } catch (CryptoException $e) { |
|
| 55 | + }catch (CryptoException $e){ |
|
| 56 | 56 | throw new EncrypterException($e->getMessage(), $e->getCode(), $e); |
| 57 | 57 | } |
| 58 | 58 | |
@@ -64,9 +64,9 @@ discard block |
||
| 64 | 64 | */ |
| 65 | 65 | public function getKey(): string |
| 66 | 66 | { |
| 67 | - try { |
|
| 67 | + try{ |
|
| 68 | 68 | return $this->key->saveToAsciiSafeString(); |
| 69 | - } catch (EnvironmentIsBrokenException $e) { |
|
| 69 | + }catch (EnvironmentIsBrokenException $e){ |
|
| 70 | 70 | throw new EncrypterException($e->getMessage(), $e->getCode(), $e); |
| 71 | 71 | } |
| 72 | 72 | } |
@@ -80,9 +80,9 @@ discard block |
||
| 80 | 80 | { |
| 81 | 81 | $packed = json_encode($data); |
| 82 | 82 | |
| 83 | - try { |
|
| 83 | + try{ |
|
| 84 | 84 | return base64_encode(Crypto::Encrypt($packed, $this->key)); |
| 85 | - } catch (\Throwable $e) { |
|
| 85 | + }catch (\Throwable $e){ |
|
| 86 | 86 | throw new EncryptException($e->getMessage(), $e->getCode(), $e); |
| 87 | 87 | } |
| 88 | 88 | } |
@@ -94,14 +94,14 @@ discard block |
||
| 94 | 94 | */ |
| 95 | 95 | public function decrypt(string $payload) |
| 96 | 96 | { |
| 97 | - try { |
|
| 97 | + try{ |
|
| 98 | 98 | $result = Crypto::Decrypt( |
| 99 | 99 | base64_decode($payload), |
| 100 | 100 | $this->key |
| 101 | 101 | ); |
| 102 | 102 | |
| 103 | 103 | return json_decode($result, true); |
| 104 | - } catch (\Throwable $e) { |
|
| 104 | + }catch (\Throwable $e){ |
|
| 105 | 105 | throw new DecryptException($e->getMessage(), $e->getCode(), $e); |
| 106 | 106 | } |
| 107 | 107 | } |
@@ -37,9 +37,12 @@ discard block |
||
| 37 | 37 | */ |
| 38 | 38 | public function __construct(string $key) |
| 39 | 39 | { |
| 40 | - try { |
|
| 40 | + try |
|
| 41 | + { |
|
| 41 | 42 | $this->key = Key::loadFromAsciiSafeString($key); |
| 42 | - } catch (CryptoException $e) { |
|
| 43 | + } |
|
| 44 | + catch (CryptoException $e) |
|
| 45 | + { |
|
| 43 | 46 | throw new EncrypterException($e->getMessage(), $e->getCode(), $e); |
| 44 | 47 | } |
| 45 | 48 | } |
@@ -50,9 +53,12 @@ discard block |
||
| 50 | 53 | public function withKey(string $key): EncrypterInterface |
| 51 | 54 | { |
| 52 | 55 | $encrypter = clone $this; |
| 53 | - try { |
|
| 56 | + try |
|
| 57 | + { |
|
| 54 | 58 | $encrypter->key = Key::loadFromAsciiSafeString($key); |
| 55 | - } catch (CryptoException $e) { |
|
| 59 | + } |
|
| 60 | + catch (CryptoException $e) |
|
| 61 | + { |
|
| 56 | 62 | throw new EncrypterException($e->getMessage(), $e->getCode(), $e); |
| 57 | 63 | } |
| 58 | 64 | |
@@ -64,9 +70,12 @@ discard block |
||
| 64 | 70 | */ |
| 65 | 71 | public function getKey(): string |
| 66 | 72 | { |
| 67 | - try { |
|
| 73 | + try |
|
| 74 | + { |
|
| 68 | 75 | return $this->key->saveToAsciiSafeString(); |
| 69 | - } catch (EnvironmentIsBrokenException $e) { |
|
| 76 | + } |
|
| 77 | + catch (EnvironmentIsBrokenException $e) |
|
| 78 | + { |
|
| 70 | 79 | throw new EncrypterException($e->getMessage(), $e->getCode(), $e); |
| 71 | 80 | } |
| 72 | 81 | } |
@@ -80,9 +89,12 @@ discard block |
||
| 80 | 89 | { |
| 81 | 90 | $packed = json_encode($data); |
| 82 | 91 | |
| 83 | - try { |
|
| 92 | + try |
|
| 93 | + { |
|
| 84 | 94 | return base64_encode(Crypto::Encrypt($packed, $this->key)); |
| 85 | - } catch (\Throwable $e) { |
|
| 95 | + } |
|
| 96 | + catch (\Throwable $e) |
|
| 97 | + { |
|
| 86 | 98 | throw new EncryptException($e->getMessage(), $e->getCode(), $e); |
| 87 | 99 | } |
| 88 | 100 | } |
@@ -94,14 +106,17 @@ discard block |
||
| 94 | 106 | */ |
| 95 | 107 | public function decrypt(string $payload) |
| 96 | 108 | { |
| 97 | - try { |
|
| 109 | + try |
|
| 110 | + { |
|
| 98 | 111 | $result = Crypto::Decrypt( |
| 99 | 112 | base64_decode($payload), |
| 100 | 113 | $this->key |
| 101 | 114 | ); |
| 102 | 115 | |
| 103 | 116 | return json_decode($result, true); |
| 104 | - } catch (\Throwable $e) { |
|
| 117 | + } |
|
| 118 | + catch (\Throwable $e) |
|
| 119 | + { |
|
| 105 | 120 | throw new DecryptException($e->getMessage(), $e->getCode(), $e); |
| 106 | 121 | } |
| 107 | 122 | } |
@@ -40,9 +40,9 @@ discard block |
||
| 40 | 40 | */ |
| 41 | 41 | public function generateKey(): string |
| 42 | 42 | { |
| 43 | - try { |
|
| 43 | + try{ |
|
| 44 | 44 | return Key::createNewRandomKey()->saveToAsciiSafeString(); |
| 45 | - } catch (CryptoException $e) { |
|
| 45 | + }catch (CryptoException $e){ |
|
| 46 | 46 | throw new EncrypterException($e->getMessage(), $e->getCode(), $e); |
| 47 | 47 | } |
| 48 | 48 | } |
@@ -52,9 +52,9 @@ discard block |
||
| 52 | 52 | */ |
| 53 | 53 | public function getKey(): string |
| 54 | 54 | { |
| 55 | - try { |
|
| 55 | + try{ |
|
| 56 | 56 | Key::loadFromAsciiSafeString($this->config->getKey()); |
| 57 | - } catch (CryptoException $e) { |
|
| 57 | + }catch (CryptoException $e){ |
|
| 58 | 58 | throw new EncrypterException($e->getMessage(), $e->getCode(), $e); |
| 59 | 59 | } |
| 60 | 60 | |
@@ -40,9 +40,12 @@ discard block |
||
| 40 | 40 | */ |
| 41 | 41 | public function generateKey(): string |
| 42 | 42 | { |
| 43 | - try { |
|
| 43 | + try |
|
| 44 | + { |
|
| 44 | 45 | return Key::createNewRandomKey()->saveToAsciiSafeString(); |
| 45 | - } catch (CryptoException $e) { |
|
| 46 | + } |
|
| 47 | + catch (CryptoException $e) |
|
| 48 | + { |
|
| 46 | 49 | throw new EncrypterException($e->getMessage(), $e->getCode(), $e); |
| 47 | 50 | } |
| 48 | 51 | } |
@@ -52,9 +55,12 @@ discard block |
||
| 52 | 55 | */ |
| 53 | 56 | public function getKey(): string |
| 54 | 57 | { |
| 55 | - try { |
|
| 58 | + try |
|
| 59 | + { |
|
| 56 | 60 | Key::loadFromAsciiSafeString($this->config->getKey()); |
| 57 | - } catch (CryptoException $e) { |
|
| 61 | + } |
|
| 62 | + catch (CryptoException $e) |
|
| 63 | + { |
|
| 58 | 64 | throw new EncrypterException($e->getMessage(), $e->getCode(), $e); |
| 59 | 65 | } |
| 60 | 66 | |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | */ |
| 93 | 93 | public function getSecured() |
| 94 | 94 | { |
| 95 | - if ($this->getProperty('secured', true) === '*') { |
|
| 95 | + if ($this->getProperty('secured', true) === '*'){ |
|
| 96 | 96 | return $this->getProperty('secured', true); |
| 97 | 97 | } |
| 98 | 98 | |
@@ -139,8 +139,8 @@ discard block |
||
| 139 | 139 | public function declaredMethods(): array |
| 140 | 140 | { |
| 141 | 141 | $methods = []; |
| 142 | - foreach ($this->getMethods() as $method) { |
|
| 143 | - if ($method->getDeclaringClass()->getName() != $this->getName()) { |
|
| 142 | + foreach ($this->getMethods() as $method){ |
|
| 143 | + if ($method->getDeclaringClass()->getName() != $this->getName()){ |
|
| 144 | 144 | continue; |
| 145 | 145 | } |
| 146 | 146 | |
@@ -174,15 +174,15 @@ discard block |
||
| 174 | 174 | self::MUTATOR_ACCESSOR => [], |
| 175 | 175 | ]; |
| 176 | 176 | |
| 177 | - foreach ((array)$this->getProperty('getters', true) as $field => $filter) { |
|
| 177 | + foreach ((array)$this->getProperty('getters', true) as $field => $filter){ |
|
| 178 | 178 | $mutators[self::MUTATOR_GETTER][$field] = $filter; |
| 179 | 179 | } |
| 180 | 180 | |
| 181 | - foreach ((array)$this->getProperty('setters', true) as $field => $filter) { |
|
| 181 | + foreach ((array)$this->getProperty('setters', true) as $field => $filter){ |
|
| 182 | 182 | $mutators[self::MUTATOR_SETTER][$field] = $filter; |
| 183 | 183 | } |
| 184 | 184 | |
| 185 | - foreach ((array)$this->getProperty('accessors', true) as $field => $filter) { |
|
| 185 | + foreach ((array)$this->getProperty('accessors', true) as $field => $filter){ |
|
| 186 | 186 | $mutators[self::MUTATOR_ACCESSOR][$field] = $filter; |
| 187 | 187 | } |
| 188 | 188 | |
@@ -200,7 +200,7 @@ discard block |
||
| 200 | 200 | */ |
| 201 | 201 | public function getProperty(string $property, bool $merge = false) |
| 202 | 202 | { |
| 203 | - if (isset($this->propertyCache[$property])) { |
|
| 203 | + if (isset($this->propertyCache[$property])){ |
|
| 204 | 204 | //Property merging and trait events are pretty slow |
| 205 | 205 | return $this->propertyCache[$property]; |
| 206 | 206 | } |
@@ -208,27 +208,27 @@ discard block |
||
| 208 | 208 | $properties = $this->reflection->getDefaultProperties(); |
| 209 | 209 | $constants = $this->reflection->getConstants(); |
| 210 | 210 | |
| 211 | - if (isset($properties[$property])) { |
|
| 211 | + if (isset($properties[$property])){ |
|
| 212 | 212 | //Read from default value |
| 213 | 213 | $value = $properties[$property]; |
| 214 | - } elseif (isset($constants[strtoupper($property)])) { |
|
| 214 | + } elseif (isset($constants[strtoupper($property)])){ |
|
| 215 | 215 | //Read from a constant |
| 216 | 216 | $value = $constants[strtoupper($property)]; |
| 217 | - } else { |
|
| 217 | + }else{ |
|
| 218 | 218 | return null; |
| 219 | 219 | } |
| 220 | 220 | |
| 221 | 221 | //Merge with parent value requested |
| 222 | - if ($merge && is_array($value) && !empty($parent = $this->parentReflection())) { |
|
| 222 | + if ($merge && is_array($value) && !empty($parent = $this->parentReflection())){ |
|
| 223 | 223 | $parentValue = $parent->getProperty($property, $merge); |
| 224 | 224 | |
| 225 | - if (is_array($parentValue)) { |
|
| 225 | + if (is_array($parentValue)){ |
|
| 226 | 226 | //Class values prior to parent values |
| 227 | 227 | $value = array_merge($parentValue, $value); |
| 228 | 228 | } |
| 229 | 229 | } |
| 230 | 230 | |
| 231 | - if (!$this->reflection->isSubclassOf(SchematicEntity::class)) { |
|
| 231 | + if (!$this->reflection->isSubclassOf(SchematicEntity::class)){ |
|
| 232 | 232 | return $value; |
| 233 | 233 | } |
| 234 | 234 | |
@@ -245,7 +245,7 @@ discard block |
||
| 245 | 245 | { |
| 246 | 246 | $parentClass = $this->reflection->getParentClass(); |
| 247 | 247 | |
| 248 | - if (!empty($parentClass) && $parentClass->getName() != static::BASE_CLASS) { |
|
| 248 | + if (!empty($parentClass) && $parentClass->getName() != static::BASE_CLASS){ |
|
| 249 | 249 | $parent = clone $this; |
| 250 | 250 | $parent->reflection = $this->getParentClass(); |
| 251 | 251 | |
@@ -92,7 +92,8 @@ discard block |
||
| 92 | 92 | */ |
| 93 | 93 | public function getSecured() |
| 94 | 94 | { |
| 95 | - if ($this->getProperty('secured', true) === '*') { |
|
| 95 | + if ($this->getProperty('secured', true) === '*') |
|
| 96 | + { |
|
| 96 | 97 | return $this->getProperty('secured', true); |
| 97 | 98 | } |
| 98 | 99 | |
@@ -139,8 +140,10 @@ discard block |
||
| 139 | 140 | public function declaredMethods(): array |
| 140 | 141 | { |
| 141 | 142 | $methods = []; |
| 142 | - foreach ($this->getMethods() as $method) { |
|
| 143 | - if ($method->getDeclaringClass()->getName() != $this->getName()) { |
|
| 143 | + foreach ($this->getMethods() as $method) |
|
| 144 | + { |
|
| 145 | + if ($method->getDeclaringClass()->getName() != $this->getName()) |
|
| 146 | + { |
|
| 144 | 147 | continue; |
| 145 | 148 | } |
| 146 | 149 | |
@@ -174,15 +177,18 @@ discard block |
||
| 174 | 177 | self::MUTATOR_ACCESSOR => [], |
| 175 | 178 | ]; |
| 176 | 179 | |
| 177 | - foreach ((array)$this->getProperty('getters', true) as $field => $filter) { |
|
| 180 | + foreach ((array)$this->getProperty('getters', true) as $field => $filter) |
|
| 181 | + { |
|
| 178 | 182 | $mutators[self::MUTATOR_GETTER][$field] = $filter; |
| 179 | 183 | } |
| 180 | 184 | |
| 181 | - foreach ((array)$this->getProperty('setters', true) as $field => $filter) { |
|
| 185 | + foreach ((array)$this->getProperty('setters', true) as $field => $filter) |
|
| 186 | + { |
|
| 182 | 187 | $mutators[self::MUTATOR_SETTER][$field] = $filter; |
| 183 | 188 | } |
| 184 | 189 | |
| 185 | - foreach ((array)$this->getProperty('accessors', true) as $field => $filter) { |
|
| 190 | + foreach ((array)$this->getProperty('accessors', true) as $field => $filter) |
|
| 191 | + { |
|
| 186 | 192 | $mutators[self::MUTATOR_ACCESSOR][$field] = $filter; |
| 187 | 193 | } |
| 188 | 194 | |
@@ -200,7 +206,8 @@ discard block |
||
| 200 | 206 | */ |
| 201 | 207 | public function getProperty(string $property, bool $merge = false) |
| 202 | 208 | { |
| 203 | - if (isset($this->propertyCache[$property])) { |
|
| 209 | + if (isset($this->propertyCache[$property])) |
|
| 210 | + { |
|
| 204 | 211 | //Property merging and trait events are pretty slow |
| 205 | 212 | return $this->propertyCache[$property]; |
| 206 | 213 | } |
@@ -208,27 +215,35 @@ discard block |
||
| 208 | 215 | $properties = $this->reflection->getDefaultProperties(); |
| 209 | 216 | $constants = $this->reflection->getConstants(); |
| 210 | 217 | |
| 211 | - if (isset($properties[$property])) { |
|
| 218 | + if (isset($properties[$property])) |
|
| 219 | + { |
|
| 212 | 220 | //Read from default value |
| 213 | 221 | $value = $properties[$property]; |
| 214 | - } elseif (isset($constants[strtoupper($property)])) { |
|
| 222 | + } |
|
| 223 | + elseif (isset($constants[strtoupper($property)])) |
|
| 224 | + { |
|
| 215 | 225 | //Read from a constant |
| 216 | 226 | $value = $constants[strtoupper($property)]; |
| 217 | - } else { |
|
| 227 | + } |
|
| 228 | + else |
|
| 229 | + { |
|
| 218 | 230 | return null; |
| 219 | 231 | } |
| 220 | 232 | |
| 221 | 233 | //Merge with parent value requested |
| 222 | - if ($merge && is_array($value) && !empty($parent = $this->parentReflection())) { |
|
| 234 | + if ($merge && is_array($value) && !empty($parent = $this->parentReflection())) |
|
| 235 | + { |
|
| 223 | 236 | $parentValue = $parent->getProperty($property, $merge); |
| 224 | 237 | |
| 225 | - if (is_array($parentValue)) { |
|
| 238 | + if (is_array($parentValue)) |
|
| 239 | + { |
|
| 226 | 240 | //Class values prior to parent values |
| 227 | 241 | $value = array_merge($parentValue, $value); |
| 228 | 242 | } |
| 229 | 243 | } |
| 230 | 244 | |
| 231 | - if (!$this->reflection->isSubclassOf(SchematicEntity::class)) { |
|
| 245 | + if (!$this->reflection->isSubclassOf(SchematicEntity::class)) |
|
| 246 | + { |
|
| 232 | 247 | return $value; |
| 233 | 248 | } |
| 234 | 249 | |
@@ -245,7 +260,8 @@ discard block |
||
| 245 | 260 | { |
| 246 | 261 | $parentClass = $this->reflection->getParentClass(); |
| 247 | 262 | |
| 248 | - if (!empty($parentClass) && $parentClass->getName() != static::BASE_CLASS) { |
|
| 263 | + if (!empty($parentClass) && $parentClass->getName() != static::BASE_CLASS) |
|
| 264 | + { |
|
| 249 | 265 | $parent = clone $this; |
| 250 | 266 | $parent->reflection = $this->getParentClass(); |
| 251 | 267 | |
@@ -72,15 +72,15 @@ discard block |
||
| 72 | 72 | */ |
| 73 | 73 | protected function isFillable(string $field): bool |
| 74 | 74 | { |
| 75 | - if (static::FILLABLE === '*') { |
|
| 75 | + if (static::FILLABLE === '*'){ |
|
| 76 | 76 | return true; |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | - if (!empty(static::FILLABLE)) { |
|
| 79 | + if (!empty(static::FILLABLE)){ |
|
| 80 | 80 | return in_array($field, static::FILLABLE); |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | - if (static::SECURED === '*') { |
|
| 83 | + if (static::SECURED === '*'){ |
|
| 84 | 84 | return false; |
| 85 | 85 | } |
| 86 | 86 | |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | protected function getMutator(string $field, string $mutator) |
| 100 | 100 | { |
| 101 | 101 | $target = []; |
| 102 | - switch ($mutator) { |
|
| 102 | + switch ($mutator){ |
|
| 103 | 103 | case ModelSchema::MUTATOR_ACCESSOR: |
| 104 | 104 | $target = static::ACCESSORS; |
| 105 | 105 | break; |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | break; |
| 112 | 112 | } |
| 113 | 113 | |
| 114 | - if (isset($target[$field])) { |
|
| 114 | + if (isset($target[$field])){ |
|
| 115 | 115 | return $target[$field]; |
| 116 | 116 | } |
| 117 | 117 | |
@@ -72,15 +72,18 @@ discard block |
||
| 72 | 72 | */ |
| 73 | 73 | protected function isFillable(string $field): bool |
| 74 | 74 | { |
| 75 | - if (static::FILLABLE === '*') { |
|
| 75 | + if (static::FILLABLE === '*') |
|
| 76 | + { |
|
| 76 | 77 | return true; |
| 77 | 78 | } |
| 78 | 79 | |
| 79 | - if (!empty(static::FILLABLE)) { |
|
| 80 | + if (!empty(static::FILLABLE)) |
|
| 81 | + { |
|
| 80 | 82 | return in_array($field, static::FILLABLE); |
| 81 | 83 | } |
| 82 | 84 | |
| 83 | - if (static::SECURED === '*') { |
|
| 85 | + if (static::SECURED === '*') |
|
| 86 | + { |
|
| 84 | 87 | return false; |
| 85 | 88 | } |
| 86 | 89 | |
@@ -99,7 +102,8 @@ discard block |
||
| 99 | 102 | protected function getMutator(string $field, string $mutator) |
| 100 | 103 | { |
| 101 | 104 | $target = []; |
| 102 | - switch ($mutator) { |
|
| 105 | + switch ($mutator) |
|
| 106 | + { |
|
| 103 | 107 | case ModelSchema::MUTATOR_ACCESSOR: |
| 104 | 108 | $target = static::ACCESSORS; |
| 105 | 109 | break; |
@@ -111,7 +115,8 @@ discard block |
||
| 111 | 115 | break; |
| 112 | 116 | } |
| 113 | 117 | |
| 114 | - if (isset($target[$field])) { |
|
| 118 | + if (isset($target[$field])) |
|
| 119 | + { |
|
| 115 | 120 | return $target[$field]; |
| 116 | 121 | } |
| 117 | 122 | |