Completed
Pull Request — master (#27)
by Bernardo Vieira da
03:37 queued 01:41
created
src/Adapter/LocalStorage.php 2 patches
Doc Comments   +6 added lines, -1 removed lines patch added patch discarded remove patch
@@ -25,6 +25,7 @@  discard block
 block discarded – undo
25 25
 
26 26
     /**
27 27
      * Constructor for LocalStorage adapter
28
+     * @param \Symfony\Component\Filesystem\Filesystem $service
28 29
      */
29 30
     public function __construct($service, array $parameters, $localTmpDir)
30 31
     {
@@ -123,6 +124,10 @@  discard block
 block discarded – undo
123 124
         $this->service->mkdir($this->absolutePath.'/'.$dir);
124 125
     }
125 126
 
127
+    /**
128
+     * @param string $originFile
129
+     * @param string $targetFile
130
+     */
126 131
     public function copy($originFile, $targetFile)
127 132
     {
128 133
         $originFile = $this->pathOrUrlToPath($originFile);
@@ -220,7 +225,7 @@  discard block
 block discarded – undo
220 225
 
221 226
     /**
222 227
      * @param  string $input
223
-     * @return array  The path to the file inside the file system. Does not contain a preceding
228
+     * @return string  The path to the file inside the file system. Does not contain a preceding
224 229
      *                slash.
225 230
      */
226 231
     private function pathOrUrlToPath($input)
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
     {
31 31
         $this->service = $service;
32 32
 
33
-        $absolutePathNormalised = '/' . trim($parameters['path'], '/');
33
+        $absolutePathNormalised = '/'.trim($parameters['path'], '/');
34 34
         if (is_dir($absolutePathNormalised) && realpath($absolutePathNormalised)) {
35 35
             $this->absolutePath = realpath($absolutePathNormalised);
36 36
         } else {
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
             $fullPath = $path;
54 54
         } else {
55 55
             $path = $this->pathOrUrlToPath($path);
56
-            $fullPath = $this->absolutePath . '/' . $path;
56
+            $fullPath = $this->absolutePath.'/'.$path;
57 57
         }
58 58
 
59 59
         return (string) file_get_contents($fullPath);
@@ -113,10 +113,10 @@  discard block
 block discarded – undo
113 113
     {
114 114
         $directory = $this->pathOrUrlToPath($directory);
115 115
 
116
-        $files = ServerFileSystem::getFilesInDirectory($this->absolutePath . '/' . $directory);
116
+        $files = ServerFileSystem::getFilesInDirectory($this->absolutePath.'/'.$directory);
117 117
 
118
-        return array_map(function ($file) {
119
-            return str_replace($this->absolutePath . '/', '', $file);
118
+        return array_map(function($file) {
119
+            return str_replace($this->absolutePath.'/', '', $file);
120 120
         }, $files);
121 121
     }
122 122
 
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
      */
204 204
     public function getFileSize($path)
205 205
     {
206
-        $fullPath = $this->absolutePath . '/' . $this->pathOrUrlToPath($path);
206
+        $fullPath = $this->absolutePath.'/'.$this->pathOrUrlToPath($path);
207 207
 
208 208
         return filesize($fullPath);
209 209
     }
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
     {
216 216
         $content = $this->read($path);
217 217
         $extension = pathinfo($path, PATHINFO_EXTENSION);
218
-        $target = tempnam($this->localTmpDir, null) . '.' . $extension;
218
+        $target = tempnam($this->localTmpDir, null).'.'.$extension;
219 219
 
220 220
         file_put_contents($target, $content);
221 221
 
Please login to merge, or discard this patch.
src/Factory/FileSystemFactory.php 1 patch
Doc Comments   +5 added lines patch added patch discarded remove patch
@@ -17,6 +17,10 @@  discard block
 block discarded – undo
17 17
     private $config;
18 18
     private $tmpDir;
19 19
 
20
+    /**
21
+     * @param string $defaultFileSystem
22
+     * @param string $tmpDir
23
+     */
20 24
     public function __construct($defaultFileSystem, $config, $tmpDir)
21 25
     {
22 26
         $this->defaultFileSystem = $defaultFileSystem;
@@ -25,6 +29,7 @@  discard block
 block discarded – undo
25 29
     }
26 30
 
27 31
     /**
32
+     * @param string $adapterName
28 33
      * @return \Partnermarketing\FileSystemBundle\Adapter\AdapterInterface
29 34
      */
30 35
     public function build($adapterName = null)
Please login to merge, or discard this patch.
src/Tests/Unit/Adapter/LocalStorageTest.php 1 patch
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -2,7 +2,6 @@
 block discarded – undo
2 2
 
3 3
 namespace Partnermarketing\FileSystemBundle\Tests\Unit\Adapter;
4 4
 
5
-use Partnermarketing\FileSystemBundle\Adapter\LocalStorage;
6 5
 use Partnermarketing\FileSystemBundle\Factory\FileSystemFactory;
7 6
 
8 7
 class LocalStorageTest extends \PHPUnit_Framework_TestCase
Please login to merge, or discard this patch.
src/Tests/Unit/Factory/FileSystemFactoryTest.php 1 patch
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -3,7 +3,6 @@
 block discarded – undo
3 3
 namespace Partnermarketing\FileSystemBundle\Tests\Functional\Factory;
4 4
 
5 5
 use Partnermarketing\FileSystemBundle\Factory\FileSystemFactory;
6
-use Partnermarketing\TestBundle\Tests\Base\BaseFunctionalTest;
7 6
 
8 7
 class FileSystemFactoryTest extends \PHPUnit_Framework_TestCase
9 8
 {
Please login to merge, or discard this patch.
src/Command/FindCommand.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
     {
33 33
         $adapterName = $input->getArgument('adapter');
34 34
         if (!in_array($adapterName, $this->availableAdapters)) {
35
-            $output->writeln('Invalid adapter name supplied! Adapters available: ' . implode(', ', $this->availableAdapters));
35
+            $output->writeln('Invalid adapter name supplied! Adapters available: '.implode(', ', $this->availableAdapters));
36 36
 
37 37
             return;
38 38
         }
@@ -43,9 +43,9 @@  discard block
 block discarded – undo
43 43
         $filename = $input->getArgument('filename');
44 44
 
45 45
         if ($fileSystem->exists($filename)) {
46
-            $output->writeln('File was found using adapter (' . $adapterName . ')');
46
+            $output->writeln('File was found using adapter ('.$adapterName.')');
47 47
         } else {
48
-            $output->writeln('File not found using adapter (' . $adapterName . ')');
48
+            $output->writeln('File not found using adapter ('.$adapterName.')');
49 49
         }
50 50
     }
51 51
 }
Please login to merge, or discard this patch.
src/Utility/PathHelper.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@
 block discarded – undo
38 38
         $withoutExtensionAndWithoutQueryString = implode('.', $pathParts);
39 39
 
40 40
         if (count($extensionAndQueryStringParts) === 2) {
41
-            return $withoutExtensionAndWithoutQueryString . '?' . $extensionAndQueryStringParts[1];
41
+            return $withoutExtensionAndWithoutQueryString.'?'.$extensionAndQueryStringParts[1];
42 42
         } else {
43 43
             return $withoutExtensionAndWithoutQueryString;
44 44
         }
Please login to merge, or discard this patch.
src/Tests/Unit/ServerFileSystem/ServerFileSystemTest.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 
16 16
     public function testGetFilesInDirectoryIsRecursiveAndAlphabetical()
17 17
     {
18
-        $files = ServerFileSystem::getFilesInDirectory(__DIR__  . '/../');
18
+        $files = ServerFileSystem::getFilesInDirectory(__DIR__.'/../');
19 19
 
20 20
         $this->assertCount(6, $files);
21 21
         $this->assertStringEndsWith('Unit/Adapter/LocalStorageTest.php', $files[0]);
@@ -24,16 +24,16 @@  discard block
 block discarded – undo
24 24
 
25 25
     public function testDeleteFilesInDirectoryRecursively()
26 26
     {
27
-        $dir = __DIR__ . '/deleteFilesInDirectoryRecursively/';
27
+        $dir = __DIR__.'/deleteFilesInDirectoryRecursively/';
28 28
 
29 29
         if (!is_dir($dir)) {
30 30
             mkdir($dir);
31 31
         }
32
-        file_put_contents($dir . '1.txt', '1');
33
-        file_put_contents($dir . '2.txt', '2');
34
-        mkdir($dir . 'subdir');
35
-        file_put_contents($dir . 'subdir/3.txt', '3');
36
-        file_put_contents($dir . 'subdir/4.txt', '4');
32
+        file_put_contents($dir.'1.txt', '1');
33
+        file_put_contents($dir.'2.txt', '2');
34
+        mkdir($dir.'subdir');
35
+        file_put_contents($dir.'subdir/3.txt', '3');
36
+        file_put_contents($dir.'subdir/4.txt', '4');
37 37
 
38 38
         $filesBefore = ServerFileSystem::getFilesInDirectory($dir);
39 39
         $this->assertCount(4, $filesBefore);
Please login to merge, or discard this patch.
src/Adapter/AmazonS3.php 2 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -230,10 +230,10 @@
 block discarded – undo
230 230
     }
231 231
 
232 232
     /**
233
-    * Ensures the specified bucket exists. If is does not, and create is true, it will try to create it.
234
-    *
235
-    * @return boolean
236
-    */
233
+     * Ensures the specified bucket exists. If is does not, and create is true, it will try to create it.
234
+     *
235
+     * @return boolean
236
+     */
237 237
     private function ensureBucketExists()
238 238
     {
239 239
         if ($this->haveEnsuredBucketExists) {
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -169,8 +169,8 @@  discard block
 block discarded – undo
169 169
         /*
170 170
          * Add '/' character to the directories if necessary
171 171
          */
172
-        $sourceDir = $sourceDir . (substr($sourceDir, -1) == '/' ? '' : '/');
173
-        $targetDir = $targetDir . (substr($targetDir, -1) == '/' ? '' : '/');
172
+        $sourceDir = $sourceDir.(substr($sourceDir, -1) == '/' ? '' : '/');
173
+        $targetDir = $targetDir.(substr($targetDir, -1) == '/' ? '' : '/');
174 174
 
175 175
         $this->ensureBucketExists();
176 176
 
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
         $batch = array();
180 180
         for ($i = 0; $i < count($files); $i++) {
181 181
             $targetFile = str_replace($sourceDir, "", $files[$i]);
182
-            $batch[] =  $this->service->getCommand('CopyObject', array(
182
+            $batch[] = $this->service->getCommand('CopyObject', array(
183 183
                 'Bucket'     => $targetBucket,
184 184
                 'Key'        => "{$targetDir}{$targetFile}",
185 185
                 'CopySource' => "{$sourceBucket}/{$files[$i]}",
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
     {
302 302
         $content = $this->read($path);
303 303
         $extension = pathinfo($path, PATHINFO_EXTENSION);
304
-        $target = tempnam($this->localTmpDir, null) . '.' . $extension;
304
+        $target = tempnam($this->localTmpDir, null).'.'.$extension;
305 305
 
306 306
         file_put_contents($target, $content);
307 307
 
Please login to merge, or discard this patch.