| @@ -25,6 +25,7 @@ discard block | ||
| 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 | ||
| 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 | ||
| 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) | 
| @@ -30,7 +30,7 @@ discard block | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | |
| @@ -17,6 +17,10 @@ discard block | ||
| 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 | ||
| 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) | 
| @@ -2,7 +2,6 @@ | ||
| 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 | 
| @@ -3,7 +3,6 @@ | ||
| 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 |  { | 
| @@ -38,7 +38,7 @@ | ||
| 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 | } | 
| @@ -15,7 +15,7 @@ discard block | ||
| 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 | ||
| 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); | 
| @@ -230,10 +230,10 @@ | ||
| 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) { | 
| @@ -169,8 +169,8 @@ discard block | ||
| 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 | ||
| 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 | ||
| 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 | |
| @@ -33,7 +33,7 @@ discard block | ||
| 33 | 33 |          $adapterName = $input->getArgument('adapter'); | 
| 34 | 34 |          if (!in_array($adapterName, $this->availableAdapters)) { | 
| 35 | 35 | $output->writeln( | 
| 36 | -                'Invalid adapter name supplied! Adapters available: ' . implode(', ', $this->availableAdapters) | |
| 36 | +                'Invalid adapter name supplied! Adapters available: '.implode(', ', $this->availableAdapters) | |
| 37 | 37 | ); | 
| 38 | 38 | |
| 39 | 39 | return; | 
| @@ -45,9 +45,9 @@ discard block | ||
| 45 | 45 |          $filename = $input->getArgument('filename'); | 
| 46 | 46 | |
| 47 | 47 |          if ($fileSystem->exists($filename)) { | 
| 48 | -            $output->writeln('File was found using adapter (' . $adapterName . ')'); | |
| 48 | +            $output->writeln('File was found using adapter ('.$adapterName.')'); | |
| 49 | 49 |          } else { | 
| 50 | -            $output->writeln('File not found using adapter (' . $adapterName . ')'); | |
| 50 | +            $output->writeln('File not found using adapter ('.$adapterName.')'); | |
| 51 | 51 | } | 
| 52 | 52 | } | 
| 53 | 53 | } |