@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | * |
| 87 | 87 | * @param string $key |
| 88 | 88 | * |
| 89 | - * @return string|boolean if cannot read content |
|
| 89 | + * @return string if cannot read content |
|
| 90 | 90 | */ |
| 91 | 91 | public function read($key) |
| 92 | 92 | { |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | * |
| 160 | 160 | * @param string $key |
| 161 | 161 | * |
| 162 | - * @return integer|boolean An UNIX like timestamp or false |
|
| 162 | + * @return string|false An UNIX like timestamp or false |
|
| 163 | 163 | */ |
| 164 | 164 | public function mtime($key) |
| 165 | 165 | { |
@@ -18,7 +18,7 @@ |
||
| 18 | 18 | * @author Daniel Richter <[email protected]> |
| 19 | 19 | */ |
| 20 | 20 | class OpenCloud implements Adapter, |
| 21 | - ChecksumCalculator |
|
| 21 | + ChecksumCalculator |
|
| 22 | 22 | { |
| 23 | 23 | /** |
| 24 | 24 | * @var Service |
@@ -143,7 +143,7 @@ |
||
| 143 | 143 | public function keys() |
| 144 | 144 | { |
| 145 | 145 | $objectList = $this->getContainer()->objectList(); |
| 146 | - $keys = array (); |
|
| 146 | + $keys = array(); |
|
| 147 | 147 | |
| 148 | 148 | while ($object = $objectList->next()) { |
| 149 | 149 | $keys[] = $object->getName(); |
@@ -109,8 +109,7 @@ discard block |
||
| 109 | 109 | { |
| 110 | 110 | try { |
| 111 | 111 | $object = $this->getContainer()->uploadObject($key, $content); |
| 112 | - } |
|
| 113 | - catch (CreateUpdateError $updateError) { |
|
| 112 | + } catch (CreateUpdateError $updateError) { |
|
| 114 | 113 | return false; |
| 115 | 114 | } |
| 116 | 115 | |
@@ -185,8 +184,7 @@ discard block |
||
| 185 | 184 | |
| 186 | 185 | try { |
| 187 | 186 | $object->delete(); |
| 188 | - } |
|
| 189 | - catch (DeleteError $deleteError) { |
|
| 187 | + } catch (DeleteError $deleteError) { |
|
| 190 | 188 | return false; |
| 191 | 189 | } |
| 192 | 190 | |
@@ -249,8 +247,7 @@ discard block |
||
| 249 | 247 | { |
| 250 | 248 | try { |
| 251 | 249 | return $this->getContainer()->getObject($key); |
| 252 | - } |
|
| 253 | - catch (ObjectNotFoundException $objFetchError) { |
|
| 250 | + } catch (ObjectNotFoundException $objFetchError) { |
|
| 254 | 251 | return false; |
| 255 | 252 | } |
| 256 | 253 | } |
@@ -187,6 +187,10 @@ discard block |
||
| 187 | 187 | $this->initialized = true; |
| 188 | 188 | } |
| 189 | 189 | |
| 190 | + /** |
|
| 191 | + * @param string|null $directory |
|
| 192 | + * @param boolean $create |
|
| 193 | + */ |
|
| 190 | 194 | protected function ensureDirectoryExists($directory, $create) |
| 191 | 195 | { |
| 192 | 196 | $pwd = $this->sftp->pwd(); |
@@ -201,6 +205,9 @@ discard block |
||
| 201 | 205 | } |
| 202 | 206 | } |
| 203 | 207 | |
| 208 | + /** |
|
| 209 | + * @param string $key |
|
| 210 | + */ |
|
| 204 | 211 | protected function computePath($key) |
| 205 | 212 | { |
| 206 | 213 | return $this->directory.'/'.ltrim($key, '/'); |
@@ -8,8 +8,8 @@ |
||
| 8 | 8 | use Gaufrette\File; |
| 9 | 9 | |
| 10 | 10 | class PhpseclibSftp implements Adapter, |
| 11 | - FileFactory, |
|
| 12 | - ListKeysAware |
|
| 11 | + FileFactory, |
|
| 12 | + ListKeysAware |
|
| 13 | 13 | { |
| 14 | 14 | protected $sftp; |
| 15 | 15 | protected $directory; |
@@ -136,7 +136,7 @@ |
||
| 136 | 136 | * Returns the stat of a file in the zip archive |
| 137 | 137 | * (name, index, crc, mtime, compression size, compression method, filesize) |
| 138 | 138 | * |
| 139 | - * @param $key |
|
| 139 | + * @param string $key |
|
| 140 | 140 | * @return array|bool |
| 141 | 141 | */ |
| 142 | 142 | public function getStat($key) |
@@ -167,36 +167,36 @@ |
||
| 167 | 167 | |
| 168 | 168 | if (true !== ($resultCode = $this->zipArchive->open($this->zipFile, ZipArchive::CREATE))) { |
| 169 | 169 | switch ($resultCode) { |
| 170 | - case ZipArchive::ER_EXISTS: |
|
| 171 | - $errMsg = 'File already exists.'; |
|
| 172 | - break; |
|
| 173 | - case ZipArchive::ER_INCONS: |
|
| 174 | - $errMsg = 'Zip archive inconsistent.'; |
|
| 175 | - break; |
|
| 176 | - case ZipArchive::ER_INVAL: |
|
| 177 | - $errMsg = 'Invalid argument.'; |
|
| 178 | - break; |
|
| 179 | - case ZipArchive::ER_MEMORY: |
|
| 180 | - $errMsg = 'Malloc failure.'; |
|
| 181 | - break; |
|
| 182 | - case ZipArchive::ER_NOENT: |
|
| 183 | - $errMsg = 'Invalid argument.'; |
|
| 184 | - break; |
|
| 185 | - case ZipArchive::ER_NOZIP: |
|
| 186 | - $errMsg = 'Not a zip archive.'; |
|
| 187 | - break; |
|
| 188 | - case ZipArchive::ER_OPEN: |
|
| 189 | - $errMsg = 'Can\'t open file.'; |
|
| 190 | - break; |
|
| 191 | - case ZipArchive::ER_READ: |
|
| 192 | - $errMsg = 'Read error.'; |
|
| 193 | - break; |
|
| 194 | - case ZipArchive::ER_SEEK; |
|
| 195 | - $errMsg = 'Seek error.'; |
|
| 196 | - break; |
|
| 197 | - default: |
|
| 198 | - $errMsg = 'Unknown error.'; |
|
| 199 | - break; |
|
| 170 | + case ZipArchive::ER_EXISTS: |
|
| 171 | + $errMsg = 'File already exists.'; |
|
| 172 | + break; |
|
| 173 | + case ZipArchive::ER_INCONS: |
|
| 174 | + $errMsg = 'Zip archive inconsistent.'; |
|
| 175 | + break; |
|
| 176 | + case ZipArchive::ER_INVAL: |
|
| 177 | + $errMsg = 'Invalid argument.'; |
|
| 178 | + break; |
|
| 179 | + case ZipArchive::ER_MEMORY: |
|
| 180 | + $errMsg = 'Malloc failure.'; |
|
| 181 | + break; |
|
| 182 | + case ZipArchive::ER_NOENT: |
|
| 183 | + $errMsg = 'Invalid argument.'; |
|
| 184 | + break; |
|
| 185 | + case ZipArchive::ER_NOZIP: |
|
| 186 | + $errMsg = 'Not a zip archive.'; |
|
| 187 | + break; |
|
| 188 | + case ZipArchive::ER_OPEN: |
|
| 189 | + $errMsg = 'Can\'t open file.'; |
|
| 190 | + break; |
|
| 191 | + case ZipArchive::ER_READ: |
|
| 192 | + $errMsg = 'Read error.'; |
|
| 193 | + break; |
|
| 194 | + case ZipArchive::ER_SEEK; |
|
| 195 | + $errMsg = 'Seek error.'; |
|
| 196 | + break; |
|
| 197 | + default: |
|
| 198 | + $errMsg = 'Unknown error.'; |
|
| 199 | + break; |
|
| 200 | 200 | } |
| 201 | 201 | |
| 202 | 202 | throw new \RuntimeException(sprintf('%s', $errMsg)); |
@@ -268,7 +268,7 @@ discard block |
||
| 268 | 268 | /** |
| 269 | 269 | * Gets a new stream instance of the specified file. |
| 270 | 270 | * |
| 271 | - * @param $key |
|
| 271 | + * @param string $key |
|
| 272 | 272 | * @return Stream|Stream\InMemoryBuffer |
| 273 | 273 | */ |
| 274 | 274 | public function createStream($key) |
@@ -283,7 +283,7 @@ discard block |
||
| 283 | 283 | /** |
| 284 | 284 | * Creates a new file in a filesystem. |
| 285 | 285 | * |
| 286 | - * @param $key |
|
| 286 | + * @param string $key |
|
| 287 | 287 | * @return File |
| 288 | 288 | */ |
| 289 | 289 | public function createFile($key) |
@@ -72,11 +72,11 @@ discard block |
||
| 72 | 72 | throw new Exception\UnexpectedFile($targetKey); |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | - if (! $this->adapter->rename($sourceKey, $targetKey)) { |
|
| 75 | + if (!$this->adapter->rename($sourceKey, $targetKey)) { |
|
| 76 | 76 | throw new \RuntimeException(sprintf('Could not rename the "%s" key to "%s".', $sourceKey, $targetKey)); |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | - if($this->isFileInRegister($sourceKey)) { |
|
| 79 | + if ($this->isFileInRegister($sourceKey)) { |
|
| 80 | 80 | $this->fileRegister[$targetKey] = $this->fileRegister[$sourceKey]; |
| 81 | 81 | unset($this->fileRegister[$sourceKey]); |
| 82 | 82 | } |
@@ -288,7 +288,7 @@ discard block |
||
| 288 | 288 | */ |
| 289 | 289 | public function createFile($key) |
| 290 | 290 | { |
| 291 | - if(false === $this->isFileInRegister($key)) { |
|
| 291 | + if (false === $this->isFileInRegister($key)) { |
|
| 292 | 292 | if ($this->adapter instanceof Adapter\FileFactory) { |
| 293 | 293 | $this->fileRegister[$key] = $this->adapter->createFile($key, $this); |
| 294 | 294 | } else { |
@@ -332,7 +332,7 @@ discard block |
||
| 332 | 332 | */ |
| 333 | 333 | private function assertHasFile($key) |
| 334 | 334 | { |
| 335 | - if (! empty($key) && ! $this->has($key)) { |
|
| 335 | + if (!empty($key) && !$this->has($key)) { |
|
| 336 | 336 | throw new Exception\FileNotFound($key); |
| 337 | 337 | } |
| 338 | 338 | } |
@@ -207,7 +207,7 @@ |
||
| 207 | 207 | |
| 208 | 208 | /** |
| 209 | 209 | * @param string $path |
| 210 | - * @return mixed |
|
| 210 | + * @return boolean |
|
| 211 | 211 | */ |
| 212 | 212 | public function unlink($path) |
| 213 | 213 | { |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | { |
| 48 | 48 | static::streamWrapperUnregister($scheme); |
| 49 | 49 | |
| 50 | - if (! static::streamWrapperRegister($scheme, __CLASS__)) { |
|
| 50 | + if (!static::streamWrapperRegister($scheme, __CLASS__)) { |
|
| 51 | 51 | throw new \RuntimeException(sprintf( |
| 52 | 52 | 'Could not register stream wrapper class %s for scheme %s.', |
| 53 | 53 | __CLASS__, |
@@ -251,11 +251,11 @@ discard block |
||
| 251 | 251 | $key = substr($parts['path'], 1); |
| 252 | 252 | |
| 253 | 253 | if (null !== $parts['query']) { |
| 254 | - $key.= '?' . $parts['query']; |
|
| 254 | + $key .= '?'.$parts['query']; |
|
| 255 | 255 | } |
| 256 | 256 | |
| 257 | 257 | if (null !== $parts['fragment']) { |
| 258 | - $key.= '#' . $parts['fragment']; |
|
| 258 | + $key .= '#'.$parts['fragment']; |
|
| 259 | 259 | } |
| 260 | 260 | |
| 261 | 261 | if (empty($domain) || empty($key)) { |
@@ -41,7 +41,7 @@ |
||
| 41 | 41 | } |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | - return $prefix . implode('/', $tokens); |
|
| 44 | + return $prefix.implode('/', $tokens); |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | /** |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | */ |
| 34 | 34 | public function set($domain, Filesystem $filesystem) |
| 35 | 35 | { |
| 36 | - if (! preg_match('/^[-_a-zA-Z0-9]+$/', $domain)) { |
|
| 36 | + if (!preg_match('/^[-_a-zA-Z0-9]+$/', $domain)) { |
|
| 37 | 37 | throw new \InvalidArgumentException(sprintf( |
| 38 | 38 | 'The specified domain "%s" is not a valid domain.', |
| 39 | 39 | $domain |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | */ |
| 69 | 69 | public function get($domain) |
| 70 | 70 | { |
| 71 | - if (! $this->has($domain)) { |
|
| 71 | + if (!$this->has($domain)) { |
|
| 72 | 72 | throw new \InvalidArgumentException(sprintf( |
| 73 | 73 | 'There is no filesystem defined for the "%s" domain.', |
| 74 | 74 | $domain |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | */ |
| 88 | 88 | public function remove($domain) |
| 89 | 89 | { |
| 90 | - if (! $this->has($domain)) { |
|
| 90 | + if (!$this->has($domain)) { |
|
| 91 | 91 | throw new \InvalidArgumentException(sprintf( |
| 92 | 92 | 'Cannot remove the "%s" filesystem as it is not defined.', |
| 93 | 93 | $domain |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | public function __construct(Filesystem $filesystem, $key) |
| 27 | 27 | { |
| 28 | 28 | $this->filesystem = $filesystem; |
| 29 | - $this->key = $key; |
|
| 29 | + $this->key = $key; |
|
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | /** |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | $chunk = substr($this->content, $this->position, $count); |
| 69 | - $this->position+= Util\Size::fromContent($chunk); |
|
| 69 | + $this->position += Util\Size::fromContent($chunk); |
|
| 70 | 70 | |
| 71 | 71 | return $chunk; |
| 72 | 72 | } |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | } else { |
| 92 | 92 | $before = substr($this->content, 0, $this->position); |
| 93 | 93 | $after = $newNumBytes > $newPosition ? substr($this->content, $newPosition) : ''; |
| 94 | - $this->content = $before . $data . $after; |
|
| 94 | + $this->content = $before.$data.$after; |
|
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | $this->position = $newPosition; |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | |
| 104 | 104 | public function close() |
| 105 | 105 | { |
| 106 | - if (! $this->synchronized) { |
|
| 106 | + if (!$this->synchronized) { |
|
| 107 | 107 | $this->flush(); |
| 108 | 108 | } |
| 109 | 109 | } |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | */ |
| 57 | 57 | public function read($count) |
| 58 | 58 | { |
| 59 | - if (! $this->fileHandle) { |
|
| 59 | + if (!$this->fileHandle) { |
|
| 60 | 60 | return false; |
| 61 | 61 | } |
| 62 | 62 | |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | */ |
| 73 | 73 | public function write($data) |
| 74 | 74 | { |
| 75 | - if (! $this->fileHandle) { |
|
| 75 | + if (!$this->fileHandle) { |
|
| 76 | 76 | return false; |
| 77 | 77 | } |
| 78 | 78 | |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | */ |
| 89 | 89 | public function close() |
| 90 | 90 | { |
| 91 | - if (! $this->fileHandle) { |
|
| 91 | + if (!$this->fileHandle) { |
|
| 92 | 92 | return false; |
| 93 | 93 | } |
| 94 | 94 | |