@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | * @param string $namespace |
| 19 | 19 | * @return array |
| 20 | 20 | */ |
| 21 | - public function load($locale, $group, $namespace = null); |
|
| 21 | + public function load( $locale, $group, $namespace = null ); |
|
| 22 | 22 | |
| 23 | 23 | /** |
| 24 | 24 | * Add a new namespace to the loader. |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | * @param string $hint |
| 28 | 28 | * @return void |
| 29 | 29 | */ |
| 30 | - public function addNamespace($namespace, $hint); |
|
| 30 | + public function addNamespace( $namespace, $hint ); |
|
| 31 | 31 | |
| 32 | 32 | /** |
| 33 | 33 | * Get an array of all the registered namespaces. |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | * |
| 16 | 16 | * @var array |
| 17 | 17 | */ |
| 18 | - protected $messages = []; |
|
| 18 | + protected $messages = [ ]; |
|
| 19 | 19 | |
| 20 | 20 | /** |
| 21 | 21 | * Load the messages for the given locale. |
@@ -25,15 +25,15 @@ discard block |
||
| 25 | 25 | * @param string $namespace |
| 26 | 26 | * @return array |
| 27 | 27 | */ |
| 28 | - public function load($locale, $group, $namespace = null) |
|
| 28 | + public function load( $locale, $group, $namespace = null ) |
|
| 29 | 29 | { |
| 30 | 30 | $namespace = $namespace ?: '*'; |
| 31 | 31 | |
| 32 | - if (isset($this->messages[$namespace][$locale][$group])) { |
|
| 33 | - return $this->messages[$namespace][$locale][$group]; |
|
| 32 | + if ( isset( $this->messages[ $namespace ][ $locale ][ $group ] ) ) { |
|
| 33 | + return $this->messages[ $namespace ][ $locale ][ $group ]; |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | - return []; |
|
| 36 | + return [ ]; |
|
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | /** |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | * @param string $hint |
| 44 | 44 | * @return void |
| 45 | 45 | */ |
| 46 | - public function addNamespace($namespace, $hint) |
|
| 46 | + public function addNamespace( $namespace, $hint ) |
|
| 47 | 47 | { |
| 48 | 48 | // |
| 49 | 49 | } |
@@ -57,11 +57,11 @@ discard block |
||
| 57 | 57 | * @param string|null $namespace |
| 58 | 58 | * @return $this |
| 59 | 59 | */ |
| 60 | - public function addMessages($locale, $group, array $messages, $namespace = null) |
|
| 60 | + public function addMessages( $locale, $group, array $messages, $namespace = null ) |
|
| 61 | 61 | { |
| 62 | 62 | $namespace = $namespace ?: '*'; |
| 63 | 63 | |
| 64 | - $this->messages[$namespace][$locale][$group] = $messages; |
|
| 64 | + $this->messages[ $namespace ][ $locale ][ $group ] = $messages; |
|
| 65 | 65 | |
| 66 | 66 | return $this; |
| 67 | 67 | } |
@@ -73,6 +73,6 @@ discard block |
||
| 73 | 73 | */ |
| 74 | 74 | public function namespaces() |
| 75 | 75 | { |
| 76 | - return []; |
|
| 76 | + return [ ]; |
|
| 77 | 77 | } |
| 78 | 78 | } |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | */ |
| 32 | 32 | protected function registerNativeFilesystem() |
| 33 | 33 | { |
| 34 | - $this->app->singleton('files', function () { |
|
| 34 | + $this->app->singleton( 'files', function() { |
|
| 35 | 35 | return new Filesystem; |
| 36 | 36 | }); |
| 37 | 37 | } |
@@ -45,12 +45,12 @@ discard block |
||
| 45 | 45 | { |
| 46 | 46 | $this->registerManager(); |
| 47 | 47 | |
| 48 | - $this->app->singleton('filesystem.disk', function () { |
|
| 49 | - return $this->app['filesystem']->disk($this->getDefaultDriver()); |
|
| 48 | + $this->app->singleton( 'filesystem.disk', function() { |
|
| 49 | + return $this->app[ 'filesystem' ]->disk( $this->getDefaultDriver() ); |
|
| 50 | 50 | }); |
| 51 | 51 | |
| 52 | - $this->app->singleton('filesystem.cloud', function () { |
|
| 53 | - return $this->app['filesystem']->disk($this->getCloudDriver()); |
|
| 52 | + $this->app->singleton( 'filesystem.cloud', function() { |
|
| 53 | + return $this->app[ 'filesystem' ]->disk( $this->getCloudDriver() ); |
|
| 54 | 54 | }); |
| 55 | 55 | } |
| 56 | 56 | |
@@ -61,8 +61,8 @@ discard block |
||
| 61 | 61 | */ |
| 62 | 62 | protected function registerManager() |
| 63 | 63 | { |
| 64 | - $this->app->singleton('filesystem', function () { |
|
| 65 | - return new FilesystemManager($this->app); |
|
| 64 | + $this->app->singleton( 'filesystem', function() { |
|
| 65 | + return new FilesystemManager( $this->app ); |
|
| 66 | 66 | }); |
| 67 | 67 | } |
| 68 | 68 | |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | */ |
| 74 | 74 | protected function getDefaultDriver() |
| 75 | 75 | { |
| 76 | - return $this->app['config']['filesystems.default']; |
|
| 76 | + return $this->app[ 'config' ][ 'filesystems.default' ]; |
|
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | /** |
@@ -83,6 +83,6 @@ discard block |
||
| 83 | 83 | */ |
| 84 | 84 | protected function getCloudDriver() |
| 85 | 85 | { |
| 86 | - return $this->app['config']['filesystems.cloud']; |
|
| 86 | + return $this->app[ 'config' ][ 'filesystems.cloud' ]; |
|
| 87 | 87 | } |
| 88 | 88 | } |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | * @param \League\Flysystem\FilesystemInterface $driver |
| 43 | 43 | * @return void |
| 44 | 44 | */ |
| 45 | - public function __construct(FilesystemInterface $driver) |
|
| 45 | + public function __construct( FilesystemInterface $driver ) |
|
| 46 | 46 | { |
| 47 | 47 | $this->driver = $driver; |
| 48 | 48 | } |
@@ -53,10 +53,10 @@ discard block |
||
| 53 | 53 | * @param string $path |
| 54 | 54 | * @return void |
| 55 | 55 | */ |
| 56 | - public function assertExists($path) |
|
| 56 | + public function assertExists( $path ) |
|
| 57 | 57 | { |
| 58 | 58 | PHPUnit::assertTrue( |
| 59 | - $this->exists($path), "Unable to find a file at path [{$path}]." |
|
| 59 | + $this->exists( $path ), "Unable to find a file at path [{$path}]." |
|
| 60 | 60 | ); |
| 61 | 61 | } |
| 62 | 62 | |
@@ -66,10 +66,10 @@ discard block |
||
| 66 | 66 | * @param string $path |
| 67 | 67 | * @return void |
| 68 | 68 | */ |
| 69 | - public function assertMissing($path) |
|
| 69 | + public function assertMissing( $path ) |
|
| 70 | 70 | { |
| 71 | 71 | PHPUnit::assertFalse( |
| 72 | - $this->exists($path), "Found unexpected file at path [{$path}]." |
|
| 72 | + $this->exists( $path ), "Found unexpected file at path [{$path}]." |
|
| 73 | 73 | ); |
| 74 | 74 | } |
| 75 | 75 | |
@@ -79,9 +79,9 @@ discard block |
||
| 79 | 79 | * @param string $path |
| 80 | 80 | * @return bool |
| 81 | 81 | */ |
| 82 | - public function exists($path) |
|
| 82 | + public function exists( $path ) |
|
| 83 | 83 | { |
| 84 | - return $this->driver->has($path); |
|
| 84 | + return $this->driver->has( $path ); |
|
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | /** |
@@ -90,9 +90,9 @@ discard block |
||
| 90 | 90 | * @param string $path |
| 91 | 91 | * @return string |
| 92 | 92 | */ |
| 93 | - public function path($path) |
|
| 93 | + public function path( $path ) |
|
| 94 | 94 | { |
| 95 | - return $this->driver->getAdapter()->getPathPrefix().$path; |
|
| 95 | + return $this->driver->getAdapter()->getPathPrefix() . $path; |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | /** |
@@ -103,12 +103,12 @@ discard block |
||
| 103 | 103 | * |
| 104 | 104 | * @throws \GravityKit\GravityView\Foundation\ThirdParty\Illuminate\Contracts\Filesystem\FileNotFoundException |
| 105 | 105 | */ |
| 106 | - public function get($path) |
|
| 106 | + public function get( $path ) |
|
| 107 | 107 | { |
| 108 | 108 | try { |
| 109 | - return $this->driver->read($path); |
|
| 110 | - } catch (FileNotFoundException $e) { |
|
| 111 | - throw new ContractFileNotFoundException($path, $e->getCode(), $e); |
|
| 109 | + return $this->driver->read( $path ); |
|
| 110 | + } catch ( FileNotFoundException $e ) { |
|
| 111 | + throw new ContractFileNotFoundException( $path, $e->getCode(), $e ); |
|
| 112 | 112 | } |
| 113 | 113 | } |
| 114 | 114 | |
@@ -120,23 +120,23 @@ discard block |
||
| 120 | 120 | * @param array $options |
| 121 | 121 | * @return bool |
| 122 | 122 | */ |
| 123 | - public function put($path, $contents, $options = []) |
|
| 123 | + public function put( $path, $contents, $options = [ ] ) |
|
| 124 | 124 | { |
| 125 | - if (is_string($options)) { |
|
| 126 | - $options = ['visibility' => $options]; |
|
| 125 | + if ( is_string( $options ) ) { |
|
| 126 | + $options = [ 'visibility' => $options ]; |
|
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | // If the given contents is actually a file or uploaded file instance than we will |
| 130 | 130 | // automatically store the file using a stream. This provides a convenient path |
| 131 | 131 | // for the developer to store streams without managing them manually in code. |
| 132 | - if ($contents instanceof File || |
|
| 133 | - $contents instanceof UploadedFile) { |
|
| 134 | - return $this->putFile($path, $contents, $options); |
|
| 132 | + if ( $contents instanceof File || |
|
| 133 | + $contents instanceof UploadedFile ) { |
|
| 134 | + return $this->putFile( $path, $contents, $options ); |
|
| 135 | 135 | } |
| 136 | 136 | |
| 137 | - return is_resource($contents) |
|
| 138 | - ? $this->driver->putStream($path, $contents, $options) |
|
| 139 | - : $this->driver->put($path, $contents, $options); |
|
| 137 | + return is_resource( $contents ) |
|
| 138 | + ? $this->driver->putStream( $path, $contents, $options ) |
|
| 139 | + : $this->driver->put( $path, $contents, $options ); |
|
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | /** |
@@ -147,9 +147,9 @@ discard block |
||
| 147 | 147 | * @param array $options |
| 148 | 148 | * @return string|false |
| 149 | 149 | */ |
| 150 | - public function putFile($path, $file, $options = []) |
|
| 150 | + public function putFile( $path, $file, $options = [ ] ) |
|
| 151 | 151 | { |
| 152 | - return $this->putFileAs($path, $file, $file->hashName(), $options); |
|
| 152 | + return $this->putFileAs( $path, $file, $file->hashName(), $options ); |
|
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | /** |
@@ -161,19 +161,19 @@ discard block |
||
| 161 | 161 | * @param array $options |
| 162 | 162 | * @return string|false |
| 163 | 163 | */ |
| 164 | - public function putFileAs($path, $file, $name, $options = []) |
|
| 164 | + public function putFileAs( $path, $file, $name, $options = [ ] ) |
|
| 165 | 165 | { |
| 166 | - $stream = fopen($file->getRealPath(), 'r+'); |
|
| 166 | + $stream = fopen( $file->getRealPath(), 'r+' ); |
|
| 167 | 167 | |
| 168 | 168 | // Next, we will format the path of the file and store the file using a stream since |
| 169 | 169 | // they provide better performance than alternatives. Once we write the file this |
| 170 | 170 | // stream will get closed automatically by us so the developer doesn't have to. |
| 171 | 171 | $result = $this->put( |
| 172 | - $path = trim($path.'/'.$name, '/'), $stream, $options |
|
| 172 | + $path = trim( $path . '/' . $name, '/' ), $stream, $options |
|
| 173 | 173 | ); |
| 174 | 174 | |
| 175 | - if (is_resource($stream)) { |
|
| 176 | - fclose($stream); |
|
| 175 | + if ( is_resource( $stream ) ) { |
|
| 176 | + fclose( $stream ); |
|
| 177 | 177 | } |
| 178 | 178 | |
| 179 | 179 | return $result ? $path : false; |
@@ -185,9 +185,9 @@ discard block |
||
| 185 | 185 | * @param string $path |
| 186 | 186 | * @return string |
| 187 | 187 | */ |
| 188 | - public function getVisibility($path) |
|
| 188 | + public function getVisibility( $path ) |
|
| 189 | 189 | { |
| 190 | - if ($this->driver->getVisibility($path) == AdapterInterface::VISIBILITY_PUBLIC) { |
|
| 190 | + if ( $this->driver->getVisibility( $path ) == AdapterInterface::VISIBILITY_PUBLIC ) { |
|
| 191 | 191 | return FilesystemContract::VISIBILITY_PUBLIC; |
| 192 | 192 | } |
| 193 | 193 | |
@@ -201,9 +201,9 @@ discard block |
||
| 201 | 201 | * @param string $visibility |
| 202 | 202 | * @return void |
| 203 | 203 | */ |
| 204 | - public function setVisibility($path, $visibility) |
|
| 204 | + public function setVisibility( $path, $visibility ) |
|
| 205 | 205 | { |
| 206 | - return $this->driver->setVisibility($path, $this->parseVisibility($visibility)); |
|
| 206 | + return $this->driver->setVisibility( $path, $this->parseVisibility( $visibility ) ); |
|
| 207 | 207 | } |
| 208 | 208 | |
| 209 | 209 | /** |
@@ -214,13 +214,13 @@ discard block |
||
| 214 | 214 | * @param string $separator |
| 215 | 215 | * @return int |
| 216 | 216 | */ |
| 217 | - public function prepend($path, $data, $separator = PHP_EOL) |
|
| 217 | + public function prepend( $path, $data, $separator = PHP_EOL ) |
|
| 218 | 218 | { |
| 219 | - if ($this->exists($path)) { |
|
| 220 | - return $this->put($path, $data.$separator.$this->get($path)); |
|
| 219 | + if ( $this->exists( $path ) ) { |
|
| 220 | + return $this->put( $path, $data . $separator . $this->get( $path ) ); |
|
| 221 | 221 | } |
| 222 | 222 | |
| 223 | - return $this->put($path, $data); |
|
| 223 | + return $this->put( $path, $data ); |
|
| 224 | 224 | } |
| 225 | 225 | |
| 226 | 226 | /** |
@@ -231,13 +231,13 @@ discard block |
||
| 231 | 231 | * @param string $separator |
| 232 | 232 | * @return int |
| 233 | 233 | */ |
| 234 | - public function append($path, $data, $separator = PHP_EOL) |
|
| 234 | + public function append( $path, $data, $separator = PHP_EOL ) |
|
| 235 | 235 | { |
| 236 | - if ($this->exists($path)) { |
|
| 237 | - return $this->put($path, $this->get($path).$separator.$data); |
|
| 236 | + if ( $this->exists( $path ) ) { |
|
| 237 | + return $this->put( $path, $this->get( $path ) . $separator . $data ); |
|
| 238 | 238 | } |
| 239 | 239 | |
| 240 | - return $this->put($path, $data); |
|
| 240 | + return $this->put( $path, $data ); |
|
| 241 | 241 | } |
| 242 | 242 | |
| 243 | 243 | /** |
@@ -246,18 +246,18 @@ discard block |
||
| 246 | 246 | * @param string|array $paths |
| 247 | 247 | * @return bool |
| 248 | 248 | */ |
| 249 | - public function delete($paths) |
|
| 249 | + public function delete( $paths ) |
|
| 250 | 250 | { |
| 251 | - $paths = is_array($paths) ? $paths : func_get_args(); |
|
| 251 | + $paths = is_array( $paths ) ? $paths : func_get_args(); |
|
| 252 | 252 | |
| 253 | 253 | $success = true; |
| 254 | 254 | |
| 255 | - foreach ($paths as $path) { |
|
| 255 | + foreach ( $paths as $path ) { |
|
| 256 | 256 | try { |
| 257 | - if (! $this->driver->delete($path)) { |
|
| 257 | + if ( ! $this->driver->delete( $path ) ) { |
|
| 258 | 258 | $success = false; |
| 259 | 259 | } |
| 260 | - } catch (FileNotFoundException $e) { |
|
| 260 | + } catch ( FileNotFoundException $e ) { |
|
| 261 | 261 | $success = false; |
| 262 | 262 | } |
| 263 | 263 | } |
@@ -272,9 +272,9 @@ discard block |
||
| 272 | 272 | * @param string $to |
| 273 | 273 | * @return bool |
| 274 | 274 | */ |
| 275 | - public function copy($from, $to) |
|
| 275 | + public function copy( $from, $to ) |
|
| 276 | 276 | { |
| 277 | - return $this->driver->copy($from, $to); |
|
| 277 | + return $this->driver->copy( $from, $to ); |
|
| 278 | 278 | } |
| 279 | 279 | |
| 280 | 280 | /** |
@@ -284,9 +284,9 @@ discard block |
||
| 284 | 284 | * @param string $to |
| 285 | 285 | * @return bool |
| 286 | 286 | */ |
| 287 | - public function move($from, $to) |
|
| 287 | + public function move( $from, $to ) |
|
| 288 | 288 | { |
| 289 | - return $this->driver->rename($from, $to); |
|
| 289 | + return $this->driver->rename( $from, $to ); |
|
| 290 | 290 | } |
| 291 | 291 | |
| 292 | 292 | /** |
@@ -295,9 +295,9 @@ discard block |
||
| 295 | 295 | * @param string $path |
| 296 | 296 | * @return int |
| 297 | 297 | */ |
| 298 | - public function size($path) |
|
| 298 | + public function size( $path ) |
|
| 299 | 299 | { |
| 300 | - return $this->driver->getSize($path); |
|
| 300 | + return $this->driver->getSize( $path ); |
|
| 301 | 301 | } |
| 302 | 302 | |
| 303 | 303 | /** |
@@ -306,9 +306,9 @@ discard block |
||
| 306 | 306 | * @param string $path |
| 307 | 307 | * @return string|false |
| 308 | 308 | */ |
| 309 | - public function mimeType($path) |
|
| 309 | + public function mimeType( $path ) |
|
| 310 | 310 | { |
| 311 | - return $this->driver->getMimetype($path); |
|
| 311 | + return $this->driver->getMimetype( $path ); |
|
| 312 | 312 | } |
| 313 | 313 | |
| 314 | 314 | /** |
@@ -317,9 +317,9 @@ discard block |
||
| 317 | 317 | * @param string $path |
| 318 | 318 | * @return int |
| 319 | 319 | */ |
| 320 | - public function lastModified($path) |
|
| 320 | + public function lastModified( $path ) |
|
| 321 | 321 | { |
| 322 | - return $this->driver->getTimestamp($path); |
|
| 322 | + return $this->driver->getTimestamp( $path ); |
|
| 323 | 323 | } |
| 324 | 324 | |
| 325 | 325 | /** |
@@ -328,18 +328,18 @@ discard block |
||
| 328 | 328 | * @param string $path |
| 329 | 329 | * @return string |
| 330 | 330 | */ |
| 331 | - public function url($path) |
|
| 331 | + public function url( $path ) |
|
| 332 | 332 | { |
| 333 | 333 | $adapter = $this->driver->getAdapter(); |
| 334 | 334 | |
| 335 | - if (method_exists($adapter, 'getUrl')) { |
|
| 336 | - return $adapter->getUrl($path); |
|
| 337 | - } elseif ($adapter instanceof AwsS3Adapter) { |
|
| 338 | - return $this->getAwsUrl($adapter, $path); |
|
| 339 | - } elseif ($adapter instanceof LocalAdapter) { |
|
| 340 | - return $this->getLocalUrl($path); |
|
| 335 | + if ( method_exists( $adapter, 'getUrl' ) ) { |
|
| 336 | + return $adapter->getUrl( $path ); |
|
| 337 | + } elseif ( $adapter instanceof AwsS3Adapter ) { |
|
| 338 | + return $this->getAwsUrl( $adapter, $path ); |
|
| 339 | + } elseif ( $adapter instanceof LocalAdapter ) { |
|
| 340 | + return $this->getLocalUrl( $path ); |
|
| 341 | 341 | } else { |
| 342 | - throw new RuntimeException('This driver does not support retrieving URLs.'); |
|
| 342 | + throw new RuntimeException( 'This driver does not support retrieving URLs.' ); |
|
| 343 | 343 | } |
| 344 | 344 | } |
| 345 | 345 | |
@@ -350,10 +350,10 @@ discard block |
||
| 350 | 350 | * @param string $path |
| 351 | 351 | * @return string |
| 352 | 352 | */ |
| 353 | - protected function getAwsUrl($adapter, $path) |
|
| 353 | + protected function getAwsUrl( $adapter, $path ) |
|
| 354 | 354 | { |
| 355 | 355 | return $adapter->getClient()->getObjectUrl( |
| 356 | - $adapter->getBucket(), $adapter->getPathPrefix().$path |
|
| 356 | + $adapter->getBucket(), $adapter->getPathPrefix() . $path |
|
| 357 | 357 | ); |
| 358 | 358 | } |
| 359 | 359 | |
@@ -363,24 +363,24 @@ discard block |
||
| 363 | 363 | * @param string $path |
| 364 | 364 | * @return string |
| 365 | 365 | */ |
| 366 | - protected function getLocalUrl($path) |
|
| 366 | + protected function getLocalUrl( $path ) |
|
| 367 | 367 | { |
| 368 | 368 | $config = $this->driver->getConfig(); |
| 369 | 369 | |
| 370 | 370 | // If an explicit base URL has been set on the disk configuration then we will use |
| 371 | 371 | // it as the base URL instead of the default path. This allows the developer to |
| 372 | 372 | // have full control over the base path for this filesystem's generated URLs. |
| 373 | - if ($config->has('url')) { |
|
| 374 | - return rtrim($config->get('url'), '/').'/'.ltrim($path, '/'); |
|
| 373 | + if ( $config->has( 'url' ) ) { |
|
| 374 | + return rtrim( $config->get( 'url' ), '/' ) . '/' . ltrim( $path, '/' ); |
|
| 375 | 375 | } |
| 376 | 376 | |
| 377 | - $path = '/storage/'.$path; |
|
| 377 | + $path = '/storage/' . $path; |
|
| 378 | 378 | |
| 379 | 379 | // If the path contains "storage/public", it probably means the developer is using |
| 380 | 380 | // the default disk to generate the path instead of the "public" disk like they |
| 381 | 381 | // are really supposed to use. We will remove the public from this path here. |
| 382 | - if (Str::contains($path, '/storage/public/')) { |
|
| 383 | - return Str::replaceFirst('/public/', '/', $path); |
|
| 382 | + if ( Str::contains( $path, '/storage/public/' ) ) { |
|
| 383 | + return Str::replaceFirst( '/public/', '/', $path ); |
|
| 384 | 384 | } else { |
| 385 | 385 | return $path; |
| 386 | 386 | } |
@@ -394,24 +394,24 @@ discard block |
||
| 394 | 394 | * @param array $options |
| 395 | 395 | * @return string |
| 396 | 396 | */ |
| 397 | - public function temporaryUrl($path, $expiration, array $options = []) |
|
| 397 | + public function temporaryUrl( $path, $expiration, array $options = [ ] ) |
|
| 398 | 398 | { |
| 399 | 399 | $adapter = $this->driver->getAdapter(); |
| 400 | 400 | |
| 401 | - if (method_exists($adapter, 'getTemporaryUrl')) { |
|
| 402 | - return $adapter->getTemporaryUrl($path, $expiration, $options); |
|
| 403 | - } elseif (! $adapter instanceof AwsS3Adapter) { |
|
| 404 | - throw new RuntimeException('This driver does not support creating temporary URLs.'); |
|
| 401 | + if ( method_exists( $adapter, 'getTemporaryUrl' ) ) { |
|
| 402 | + return $adapter->getTemporaryUrl( $path, $expiration, $options ); |
|
| 403 | + } elseif ( ! $adapter instanceof AwsS3Adapter ) { |
|
| 404 | + throw new RuntimeException( 'This driver does not support creating temporary URLs.' ); |
|
| 405 | 405 | } |
| 406 | 406 | |
| 407 | 407 | $client = $adapter->getClient(); |
| 408 | 408 | |
| 409 | - $command = $client->getCommand('GetObject', array_merge([ |
|
| 409 | + $command = $client->getCommand( 'GetObject', array_merge( [ |
|
| 410 | 410 | 'Bucket' => $adapter->getBucket(), |
| 411 | - 'Key' => $adapter->getPathPrefix().$path, |
|
| 412 | - ], $options)); |
|
| 411 | + 'Key' => $adapter->getPathPrefix() . $path, |
|
| 412 | + ], $options ) ); |
|
| 413 | 413 | |
| 414 | - return (string) $client->createPresignedRequest( |
|
| 414 | + return (string)$client->createPresignedRequest( |
|
| 415 | 415 | $command, $expiration |
| 416 | 416 | )->getUri(); |
| 417 | 417 | } |
@@ -423,11 +423,11 @@ discard block |
||
| 423 | 423 | * @param bool $recursive |
| 424 | 424 | * @return array |
| 425 | 425 | */ |
| 426 | - public function files($directory = null, $recursive = false) |
|
| 426 | + public function files( $directory = null, $recursive = false ) |
|
| 427 | 427 | { |
| 428 | - $contents = $this->driver->listContents($directory, $recursive); |
|
| 428 | + $contents = $this->driver->listContents( $directory, $recursive ); |
|
| 429 | 429 | |
| 430 | - return $this->filterContentsByType($contents, 'file'); |
|
| 430 | + return $this->filterContentsByType( $contents, 'file' ); |
|
| 431 | 431 | } |
| 432 | 432 | |
| 433 | 433 | /** |
@@ -436,9 +436,9 @@ discard block |
||
| 436 | 436 | * @param string|null $directory |
| 437 | 437 | * @return array |
| 438 | 438 | */ |
| 439 | - public function allFiles($directory = null) |
|
| 439 | + public function allFiles( $directory = null ) |
|
| 440 | 440 | { |
| 441 | - return $this->files($directory, true); |
|
| 441 | + return $this->files( $directory, true ); |
|
| 442 | 442 | } |
| 443 | 443 | |
| 444 | 444 | /** |
@@ -448,11 +448,11 @@ discard block |
||
| 448 | 448 | * @param bool $recursive |
| 449 | 449 | * @return array |
| 450 | 450 | */ |
| 451 | - public function directories($directory = null, $recursive = false) |
|
| 451 | + public function directories( $directory = null, $recursive = false ) |
|
| 452 | 452 | { |
| 453 | - $contents = $this->driver->listContents($directory, $recursive); |
|
| 453 | + $contents = $this->driver->listContents( $directory, $recursive ); |
|
| 454 | 454 | |
| 455 | - return $this->filterContentsByType($contents, 'dir'); |
|
| 455 | + return $this->filterContentsByType( $contents, 'dir' ); |
|
| 456 | 456 | } |
| 457 | 457 | |
| 458 | 458 | /** |
@@ -461,9 +461,9 @@ discard block |
||
| 461 | 461 | * @param string|null $directory |
| 462 | 462 | * @return array |
| 463 | 463 | */ |
| 464 | - public function allDirectories($directory = null) |
|
| 464 | + public function allDirectories( $directory = null ) |
|
| 465 | 465 | { |
| 466 | - return $this->directories($directory, true); |
|
| 466 | + return $this->directories( $directory, true ); |
|
| 467 | 467 | } |
| 468 | 468 | |
| 469 | 469 | /** |
@@ -472,9 +472,9 @@ discard block |
||
| 472 | 472 | * @param string $path |
| 473 | 473 | * @return bool |
| 474 | 474 | */ |
| 475 | - public function makeDirectory($path) |
|
| 475 | + public function makeDirectory( $path ) |
|
| 476 | 476 | { |
| 477 | - return $this->driver->createDir($path); |
|
| 477 | + return $this->driver->createDir( $path ); |
|
| 478 | 478 | } |
| 479 | 479 | |
| 480 | 480 | /** |
@@ -483,9 +483,9 @@ discard block |
||
| 483 | 483 | * @param string $directory |
| 484 | 484 | * @return bool |
| 485 | 485 | */ |
| 486 | - public function deleteDirectory($directory) |
|
| 486 | + public function deleteDirectory( $directory ) |
|
| 487 | 487 | { |
| 488 | - return $this->driver->deleteDir($directory); |
|
| 488 | + return $this->driver->deleteDir( $directory ); |
|
| 489 | 489 | } |
| 490 | 490 | |
| 491 | 491 | /** |
@@ -505,11 +505,11 @@ discard block |
||
| 505 | 505 | * @param string $type |
| 506 | 506 | * @return array |
| 507 | 507 | */ |
| 508 | - protected function filterContentsByType($contents, $type) |
|
| 508 | + protected function filterContentsByType( $contents, $type ) |
|
| 509 | 509 | { |
| 510 | - return Collection::make($contents) |
|
| 511 | - ->where('type', $type) |
|
| 512 | - ->pluck('path') |
|
| 510 | + return Collection::make( $contents ) |
|
| 511 | + ->where( 'type', $type ) |
|
| 512 | + ->pluck( 'path' ) |
|
| 513 | 513 | ->values() |
| 514 | 514 | ->all(); |
| 515 | 515 | } |
@@ -522,20 +522,20 @@ discard block |
||
| 522 | 522 | * |
| 523 | 523 | * @throws \InvalidArgumentException |
| 524 | 524 | */ |
| 525 | - protected function parseVisibility($visibility) |
|
| 525 | + protected function parseVisibility( $visibility ) |
|
| 526 | 526 | { |
| 527 | - if (is_null($visibility)) { |
|
| 527 | + if ( is_null( $visibility ) ) { |
|
| 528 | 528 | return; |
| 529 | 529 | } |
| 530 | 530 | |
| 531 | - switch ($visibility) { |
|
| 531 | + switch ( $visibility ) { |
|
| 532 | 532 | case FilesystemContract::VISIBILITY_PUBLIC: |
| 533 | 533 | return AdapterInterface::VISIBILITY_PUBLIC; |
| 534 | 534 | case FilesystemContract::VISIBILITY_PRIVATE: |
| 535 | 535 | return AdapterInterface::VISIBILITY_PRIVATE; |
| 536 | 536 | } |
| 537 | 537 | |
| 538 | - throw new InvalidArgumentException('Unknown visibility: '.$visibility); |
|
| 538 | + throw new InvalidArgumentException( 'Unknown visibility: ' . $visibility ); |
|
| 539 | 539 | } |
| 540 | 540 | |
| 541 | 541 | /** |
@@ -547,8 +547,8 @@ discard block |
||
| 547 | 547 | * |
| 548 | 548 | * @throws \BadMethodCallException |
| 549 | 549 | */ |
| 550 | - public function __call($method, array $parameters) |
|
| 550 | + public function __call( $method, array $parameters ) |
|
| 551 | 551 | { |
| 552 | - return call_user_func_array([$this->driver, $method], $parameters); |
|
| 552 | + return call_user_func_array( [ $this->driver, $method ], $parameters ); |
|
| 553 | 553 | } |
| 554 | 554 | } |
@@ -39,14 +39,14 @@ discard block |
||
| 39 | 39 | * |
| 40 | 40 | * @var array |
| 41 | 41 | */ |
| 42 | - protected $disks = []; |
|
| 42 | + protected $disks = [ ]; |
|
| 43 | 43 | |
| 44 | 44 | /** |
| 45 | 45 | * The registered custom driver creators. |
| 46 | 46 | * |
| 47 | 47 | * @var array |
| 48 | 48 | */ |
| 49 | - protected $customCreators = []; |
|
| 49 | + protected $customCreators = [ ]; |
|
| 50 | 50 | |
| 51 | 51 | /** |
| 52 | 52 | * Create a new filesystem manager instance. |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | * @param \GravityKit\GravityView\Foundation\ThirdParty\Illuminate\Contracts\Foundation\Application $app |
| 55 | 55 | * @return void |
| 56 | 56 | */ |
| 57 | - public function __construct($app) |
|
| 57 | + public function __construct( $app ) |
|
| 58 | 58 | { |
| 59 | 59 | $this->app = $app; |
| 60 | 60 | } |
@@ -65,9 +65,9 @@ discard block |
||
| 65 | 65 | * @param string $name |
| 66 | 66 | * @return \GravityKit\GravityView\Foundation\ThirdParty\Illuminate\Contracts\Filesystem\Filesystem |
| 67 | 67 | */ |
| 68 | - public function drive($name = null) |
|
| 68 | + public function drive( $name = null ) |
|
| 69 | 69 | { |
| 70 | - return $this->disk($name); |
|
| 70 | + return $this->disk( $name ); |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | /** |
@@ -76,11 +76,11 @@ discard block |
||
| 76 | 76 | * @param string $name |
| 77 | 77 | * @return \GravityKit\GravityView\Foundation\ThirdParty\Illuminate\Contracts\Filesystem\Filesystem |
| 78 | 78 | */ |
| 79 | - public function disk($name = null) |
|
| 79 | + public function disk( $name = null ) |
|
| 80 | 80 | { |
| 81 | 81 | $name = $name ?: $this->getDefaultDriver(); |
| 82 | 82 | |
| 83 | - return $this->disks[$name] = $this->get($name); |
|
| 83 | + return $this->disks[ $name ] = $this->get( $name ); |
|
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | /** |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | { |
| 93 | 93 | $name = $this->getDefaultCloudDriver(); |
| 94 | 94 | |
| 95 | - return $this->disks[$name] = $this->get($name); |
|
| 95 | + return $this->disks[ $name ] = $this->get( $name ); |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | /** |
@@ -101,9 +101,9 @@ discard block |
||
| 101 | 101 | * @param string $name |
| 102 | 102 | * @return \GravityKit\GravityView\Foundation\ThirdParty\Illuminate\Contracts\Filesystem\Filesystem |
| 103 | 103 | */ |
| 104 | - protected function get($name) |
|
| 104 | + protected function get( $name ) |
|
| 105 | 105 | { |
| 106 | - return isset($this->disks[$name]) ? $this->disks[$name] : $this->resolve($name); |
|
| 106 | + return isset( $this->disks[ $name ] ) ? $this->disks[ $name ] : $this->resolve( $name ); |
|
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | /** |
@@ -114,20 +114,20 @@ discard block |
||
| 114 | 114 | * |
| 115 | 115 | * @throws \InvalidArgumentException |
| 116 | 116 | */ |
| 117 | - protected function resolve($name) |
|
| 117 | + protected function resolve( $name ) |
|
| 118 | 118 | { |
| 119 | - $config = $this->getConfig($name); |
|
| 119 | + $config = $this->getConfig( $name ); |
|
| 120 | 120 | |
| 121 | - if (isset($this->customCreators[$config['driver']])) { |
|
| 122 | - return $this->callCustomCreator($config); |
|
| 121 | + if ( isset( $this->customCreators[ $config[ 'driver' ] ] ) ) { |
|
| 122 | + return $this->callCustomCreator( $config ); |
|
| 123 | 123 | } |
| 124 | 124 | |
| 125 | - $driverMethod = 'create'.ucfirst($config['driver']).'Driver'; |
|
| 125 | + $driverMethod = 'create' . ucfirst( $config[ 'driver' ] ) . 'Driver'; |
|
| 126 | 126 | |
| 127 | - if (method_exists($this, $driverMethod)) { |
|
| 128 | - return $this->{$driverMethod}($config); |
|
| 127 | + if ( method_exists( $this, $driverMethod ) ) { |
|
| 128 | + return $this->{$driverMethod}( $config ); |
|
| 129 | 129 | } else { |
| 130 | - throw new InvalidArgumentException("Driver [{$config['driver']}] is not supported."); |
|
| 130 | + throw new InvalidArgumentException( "Driver [{$config[ 'driver' ]}] is not supported." ); |
|
| 131 | 131 | } |
| 132 | 132 | } |
| 133 | 133 | |
@@ -137,12 +137,12 @@ discard block |
||
| 137 | 137 | * @param array $config |
| 138 | 138 | * @return \GravityKit\GravityView\Foundation\ThirdParty\Illuminate\Contracts\Filesystem\Filesystem |
| 139 | 139 | */ |
| 140 | - protected function callCustomCreator(array $config) |
|
| 140 | + protected function callCustomCreator( array $config ) |
|
| 141 | 141 | { |
| 142 | - $driver = $this->customCreators[$config['driver']]($this->app, $config); |
|
| 142 | + $driver = $this->customCreators[ $config[ 'driver' ] ]( $this->app, $config ); |
|
| 143 | 143 | |
| 144 | - if ($driver instanceof FilesystemInterface) { |
|
| 145 | - return $this->adapt($driver); |
|
| 144 | + if ( $driver instanceof FilesystemInterface ) { |
|
| 145 | + return $this->adapt( $driver ); |
|
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | return $driver; |
@@ -154,17 +154,17 @@ discard block |
||
| 154 | 154 | * @param array $config |
| 155 | 155 | * @return \GravityKit\GravityView\Foundation\ThirdParty\Illuminate\Contracts\Filesystem\Filesystem |
| 156 | 156 | */ |
| 157 | - public function createLocalDriver(array $config) |
|
| 157 | + public function createLocalDriver( array $config ) |
|
| 158 | 158 | { |
| 159 | - $permissions = isset($config['permissions']) ? $config['permissions'] : []; |
|
| 159 | + $permissions = isset( $config[ 'permissions' ] ) ? $config[ 'permissions' ] : [ ]; |
|
| 160 | 160 | |
| 161 | - $links = Arr::get($config, 'links') === 'skip' |
|
| 161 | + $links = Arr::get( $config, 'links' ) === 'skip' |
|
| 162 | 162 | ? LocalAdapter::SKIP_LINKS |
| 163 | 163 | : LocalAdapter::DISALLOW_LINKS; |
| 164 | 164 | |
| 165 | - return $this->adapt($this->createFlysystem(new LocalAdapter( |
|
| 166 | - $config['root'], LOCK_EX, $links, $permissions |
|
| 167 | - ), $config)); |
|
| 165 | + return $this->adapt( $this->createFlysystem( new LocalAdapter( |
|
| 166 | + $config[ 'root' ], LOCK_EX, $links, $permissions |
|
| 167 | + ), $config ) ); |
|
| 168 | 168 | } |
| 169 | 169 | |
| 170 | 170 | /** |
@@ -173,15 +173,15 @@ discard block |
||
| 173 | 173 | * @param array $config |
| 174 | 174 | * @return \GravityKit\GravityView\Foundation\ThirdParty\Illuminate\Contracts\Filesystem\Filesystem |
| 175 | 175 | */ |
| 176 | - public function createFtpDriver(array $config) |
|
| 176 | + public function createFtpDriver( array $config ) |
|
| 177 | 177 | { |
| 178 | - $ftpConfig = Arr::only($config, [ |
|
| 178 | + $ftpConfig = Arr::only( $config, [ |
|
| 179 | 179 | 'host', 'username', 'password', 'port', 'root', 'passive', 'ssl', 'timeout', |
| 180 | - ]); |
|
| 180 | + ] ); |
|
| 181 | 181 | |
| 182 | - return $this->adapt($this->createFlysystem( |
|
| 183 | - new FtpAdapter($ftpConfig), $config |
|
| 184 | - )); |
|
| 182 | + return $this->adapt( $this->createFlysystem( |
|
| 183 | + new FtpAdapter( $ftpConfig ), $config |
|
| 184 | + ) ); |
|
| 185 | 185 | } |
| 186 | 186 | |
| 187 | 187 | /** |
@@ -190,17 +190,17 @@ discard block |
||
| 190 | 190 | * @param array $config |
| 191 | 191 | * @return \GravityKit\GravityView\Foundation\ThirdParty\Illuminate\Contracts\Filesystem\Cloud |
| 192 | 192 | */ |
| 193 | - public function createS3Driver(array $config) |
|
| 193 | + public function createS3Driver( array $config ) |
|
| 194 | 194 | { |
| 195 | - $s3Config = $this->formatS3Config($config); |
|
| 195 | + $s3Config = $this->formatS3Config( $config ); |
|
| 196 | 196 | |
| 197 | - $root = isset($s3Config['root']) ? $s3Config['root'] : null; |
|
| 197 | + $root = isset( $s3Config[ 'root' ] ) ? $s3Config[ 'root' ] : null; |
|
| 198 | 198 | |
| 199 | - $options = isset($config['options']) ? $config['options'] : []; |
|
| 199 | + $options = isset( $config[ 'options' ] ) ? $config[ 'options' ] : [ ]; |
|
| 200 | 200 | |
| 201 | - return $this->adapt($this->createFlysystem( |
|
| 202 | - new S3Adapter(new S3Client($s3Config), $s3Config['bucket'], $root, $options), $config |
|
| 203 | - )); |
|
| 201 | + return $this->adapt( $this->createFlysystem( |
|
| 202 | + new S3Adapter( new S3Client( $s3Config ), $s3Config[ 'bucket' ], $root, $options ), $config |
|
| 203 | + ) ); |
|
| 204 | 204 | } |
| 205 | 205 | |
| 206 | 206 | /** |
@@ -209,12 +209,12 @@ discard block |
||
| 209 | 209 | * @param array $config |
| 210 | 210 | * @return array |
| 211 | 211 | */ |
| 212 | - protected function formatS3Config(array $config) |
|
| 212 | + protected function formatS3Config( array $config ) |
|
| 213 | 213 | { |
| 214 | - $config += ['version' => 'latest']; |
|
| 214 | + $config += [ 'version' => 'latest' ]; |
|
| 215 | 215 | |
| 216 | - if ($config['key'] && $config['secret']) { |
|
| 217 | - $config['credentials'] = Arr::only($config, ['key', 'secret']); |
|
| 216 | + if ( $config[ 'key' ] && $config[ 'secret' ] ) { |
|
| 217 | + $config[ 'credentials' ] = Arr::only( $config, [ 'key', 'secret' ] ); |
|
| 218 | 218 | } |
| 219 | 219 | |
| 220 | 220 | return $config; |
@@ -226,17 +226,17 @@ discard block |
||
| 226 | 226 | * @param array $config |
| 227 | 227 | * @return \GravityKit\GravityView\Foundation\ThirdParty\Illuminate\Contracts\Filesystem\Cloud |
| 228 | 228 | */ |
| 229 | - public function createRackspaceDriver(array $config) |
|
| 229 | + public function createRackspaceDriver( array $config ) |
|
| 230 | 230 | { |
| 231 | - $client = new Rackspace($config['endpoint'], [ |
|
| 232 | - 'username' => $config['username'], 'apiKey' => $config['key'], |
|
| 233 | - ]); |
|
| 231 | + $client = new Rackspace( $config[ 'endpoint' ], [ |
|
| 232 | + 'username' => $config[ 'username' ], 'apiKey' => $config[ 'key' ], |
|
| 233 | + ] ); |
|
| 234 | 234 | |
| 235 | - $root = isset($config['root']) ? $config['root'] : null; |
|
| 235 | + $root = isset( $config[ 'root' ] ) ? $config[ 'root' ] : null; |
|
| 236 | 236 | |
| 237 | - return $this->adapt($this->createFlysystem( |
|
| 238 | - new RackspaceAdapter($this->getRackspaceContainer($client, $config), $root), $config |
|
| 239 | - )); |
|
| 237 | + return $this->adapt( $this->createFlysystem( |
|
| 238 | + new RackspaceAdapter( $this->getRackspaceContainer( $client, $config ), $root ), $config |
|
| 239 | + ) ); |
|
| 240 | 240 | } |
| 241 | 241 | |
| 242 | 242 | /** |
@@ -246,13 +246,13 @@ discard block |
||
| 246 | 246 | * @param array $config |
| 247 | 247 | * @return \OpenCloud\ObjectStore\Resource\Container |
| 248 | 248 | */ |
| 249 | - protected function getRackspaceContainer(Rackspace $client, array $config) |
|
| 249 | + protected function getRackspaceContainer( Rackspace $client, array $config ) |
|
| 250 | 250 | { |
| 251 | - $urlType = Arr::get($config, 'url_type'); |
|
| 251 | + $urlType = Arr::get( $config, 'url_type' ); |
|
| 252 | 252 | |
| 253 | - $store = $client->objectStoreService('cloudFiles', $config['region'], $urlType); |
|
| 253 | + $store = $client->objectStoreService( 'cloudFiles', $config[ 'region' ], $urlType ); |
|
| 254 | 254 | |
| 255 | - return $store->getContainer($config['container']); |
|
| 255 | + return $store->getContainer( $config[ 'container' ] ); |
|
| 256 | 256 | } |
| 257 | 257 | |
| 258 | 258 | /** |
@@ -262,11 +262,11 @@ discard block |
||
| 262 | 262 | * @param array $config |
| 263 | 263 | * @return \League\Flysystem\FlysystemInterface |
| 264 | 264 | */ |
| 265 | - protected function createFlysystem(AdapterInterface $adapter, array $config) |
|
| 265 | + protected function createFlysystem( AdapterInterface $adapter, array $config ) |
|
| 266 | 266 | { |
| 267 | - $config = Arr::only($config, ['visibility', 'disable_asserts', 'url']); |
|
| 267 | + $config = Arr::only( $config, [ 'visibility', 'disable_asserts', 'url' ] ); |
|
| 268 | 268 | |
| 269 | - return new Flysystem($adapter, count($config) > 0 ? $config : null); |
|
| 269 | + return new Flysystem( $adapter, count( $config ) > 0 ? $config : null ); |
|
| 270 | 270 | } |
| 271 | 271 | |
| 272 | 272 | /** |
@@ -275,9 +275,9 @@ discard block |
||
| 275 | 275 | * @param \League\Flysystem\FilesystemInterface $filesystem |
| 276 | 276 | * @return \GravityKit\GravityView\Foundation\ThirdParty\Illuminate\Contracts\Filesystem\Filesystem |
| 277 | 277 | */ |
| 278 | - protected function adapt(FilesystemInterface $filesystem) |
|
| 278 | + protected function adapt( FilesystemInterface $filesystem ) |
|
| 279 | 279 | { |
| 280 | - return new FilesystemAdapter($filesystem); |
|
| 280 | + return new FilesystemAdapter( $filesystem ); |
|
| 281 | 281 | } |
| 282 | 282 | |
| 283 | 283 | /** |
@@ -287,9 +287,9 @@ discard block |
||
| 287 | 287 | * @param mixed $disk |
| 288 | 288 | * @return void |
| 289 | 289 | */ |
| 290 | - public function set($name, $disk) |
|
| 290 | + public function set( $name, $disk ) |
|
| 291 | 291 | { |
| 292 | - $this->disks[$name] = $disk; |
|
| 292 | + $this->disks[ $name ] = $disk; |
|
| 293 | 293 | } |
| 294 | 294 | |
| 295 | 295 | /** |
@@ -298,9 +298,9 @@ discard block |
||
| 298 | 298 | * @param string $name |
| 299 | 299 | * @return array |
| 300 | 300 | */ |
| 301 | - protected function getConfig($name) |
|
| 301 | + protected function getConfig( $name ) |
|
| 302 | 302 | { |
| 303 | - return $this->app['config']["filesystems.disks.{$name}"]; |
|
| 303 | + return $this->app[ 'config' ][ "filesystems.disks.{$name}" ]; |
|
| 304 | 304 | } |
| 305 | 305 | |
| 306 | 306 | /** |
@@ -310,7 +310,7 @@ discard block |
||
| 310 | 310 | */ |
| 311 | 311 | public function getDefaultDriver() |
| 312 | 312 | { |
| 313 | - return $this->app['config']['filesystems.default']; |
|
| 313 | + return $this->app[ 'config' ][ 'filesystems.default' ]; |
|
| 314 | 314 | } |
| 315 | 315 | |
| 316 | 316 | /** |
@@ -320,7 +320,7 @@ discard block |
||
| 320 | 320 | */ |
| 321 | 321 | public function getDefaultCloudDriver() |
| 322 | 322 | { |
| 323 | - return $this->app['config']['filesystems.cloud']; |
|
| 323 | + return $this->app[ 'config' ][ 'filesystems.cloud' ]; |
|
| 324 | 324 | } |
| 325 | 325 | |
| 326 | 326 | /** |
@@ -330,9 +330,9 @@ discard block |
||
| 330 | 330 | * @param \Closure $callback |
| 331 | 331 | * @return $this |
| 332 | 332 | */ |
| 333 | - public function extend($driver, Closure $callback) |
|
| 333 | + public function extend( $driver, Closure $callback ) |
|
| 334 | 334 | { |
| 335 | - $this->customCreators[$driver] = $callback; |
|
| 335 | + $this->customCreators[ $driver ] = $callback; |
|
| 336 | 336 | |
| 337 | 337 | return $this; |
| 338 | 338 | } |
@@ -344,8 +344,8 @@ discard block |
||
| 344 | 344 | * @param array $parameters |
| 345 | 345 | * @return mixed |
| 346 | 346 | */ |
| 347 | - public function __call($method, $parameters) |
|
| 347 | + public function __call( $method, $parameters ) |
|
| 348 | 348 | { |
| 349 | - return $this->disk()->$method(...$parameters); |
|
| 349 | + return $this->disk()->$method( ...$parameters ); |
|
| 350 | 350 | } |
| 351 | 351 | } |
@@ -24,9 +24,9 @@ discard block |
||
| 24 | 24 | * @param string $path |
| 25 | 25 | * @return bool |
| 26 | 26 | */ |
| 27 | - public function exists($path) |
|
| 27 | + public function exists( $path ) |
|
| 28 | 28 | { |
| 29 | - return file_exists($path); |
|
| 29 | + return file_exists( $path ); |
|
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | /** |
@@ -38,13 +38,13 @@ discard block |
||
| 38 | 38 | * |
| 39 | 39 | * @throws \GravityKit\GravityView\Foundation\ThirdParty\Illuminate\Contracts\Filesystem\FileNotFoundException |
| 40 | 40 | */ |
| 41 | - public function get($path, $lock = false) |
|
| 41 | + public function get( $path, $lock = false ) |
|
| 42 | 42 | { |
| 43 | - if ($this->isFile($path)) { |
|
| 44 | - return $lock ? $this->sharedGet($path) : file_get_contents($path); |
|
| 43 | + if ( $this->isFile( $path ) ) { |
|
| 44 | + return $lock ? $this->sharedGet( $path ) : file_get_contents( $path ); |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | - throw new FileNotFoundException("File does not exist at path {$path}"); |
|
| 47 | + throw new FileNotFoundException( "File does not exist at path {$path}" ); |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | /** |
@@ -53,23 +53,23 @@ discard block |
||
| 53 | 53 | * @param string $path |
| 54 | 54 | * @return string |
| 55 | 55 | */ |
| 56 | - public function sharedGet($path) |
|
| 56 | + public function sharedGet( $path ) |
|
| 57 | 57 | { |
| 58 | 58 | $contents = ''; |
| 59 | 59 | |
| 60 | - $handle = fopen($path, 'rb'); |
|
| 60 | + $handle = fopen( $path, 'rb' ); |
|
| 61 | 61 | |
| 62 | - if ($handle) { |
|
| 62 | + if ( $handle ) { |
|
| 63 | 63 | try { |
| 64 | - if (flock($handle, LOCK_SH)) { |
|
| 65 | - clearstatcache(true, $path); |
|
| 64 | + if ( flock( $handle, LOCK_SH ) ) { |
|
| 65 | + clearstatcache( true, $path ); |
|
| 66 | 66 | |
| 67 | - $contents = fread($handle, $this->size($path) ?: 1); |
|
| 67 | + $contents = fread( $handle, $this->size( $path ) ?: 1 ); |
|
| 68 | 68 | |
| 69 | - flock($handle, LOCK_UN); |
|
| 69 | + flock( $handle, LOCK_UN ); |
|
| 70 | 70 | } |
| 71 | 71 | } finally { |
| 72 | - fclose($handle); |
|
| 72 | + fclose( $handle ); |
|
| 73 | 73 | } |
| 74 | 74 | } |
| 75 | 75 | |
@@ -84,13 +84,13 @@ discard block |
||
| 84 | 84 | * |
| 85 | 85 | * @throws \GravityKit\GravityView\Foundation\ThirdParty\Illuminate\Contracts\Filesystem\FileNotFoundException |
| 86 | 86 | */ |
| 87 | - public function getRequire($path) |
|
| 87 | + public function getRequire( $path ) |
|
| 88 | 88 | { |
| 89 | - if ($this->isFile($path)) { |
|
| 89 | + if ( $this->isFile( $path ) ) { |
|
| 90 | 90 | return require $path; |
| 91 | 91 | } |
| 92 | 92 | |
| 93 | - throw new FileNotFoundException("File does not exist at path {$path}"); |
|
| 93 | + throw new FileNotFoundException( "File does not exist at path {$path}" ); |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | /** |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | * @param string $file |
| 100 | 100 | * @return mixed |
| 101 | 101 | */ |
| 102 | - public function requireOnce($file) |
|
| 102 | + public function requireOnce( $file ) |
|
| 103 | 103 | { |
| 104 | 104 | require_once $file; |
| 105 | 105 | } |
@@ -110,9 +110,9 @@ discard block |
||
| 110 | 110 | * @param string $path |
| 111 | 111 | * @return string |
| 112 | 112 | */ |
| 113 | - public function hash($path) |
|
| 113 | + public function hash( $path ) |
|
| 114 | 114 | { |
| 115 | - return md5_file($path); |
|
| 115 | + return md5_file( $path ); |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | /** |
@@ -123,9 +123,9 @@ discard block |
||
| 123 | 123 | * @param bool $lock |
| 124 | 124 | * @return int |
| 125 | 125 | */ |
| 126 | - public function put($path, $contents, $lock = false) |
|
| 126 | + public function put( $path, $contents, $lock = false ) |
|
| 127 | 127 | { |
| 128 | - return file_put_contents($path, $contents, $lock ? LOCK_EX : 0); |
|
| 128 | + return file_put_contents( $path, $contents, $lock ? LOCK_EX : 0 ); |
|
| 129 | 129 | } |
| 130 | 130 | |
| 131 | 131 | /** |
@@ -135,13 +135,13 @@ discard block |
||
| 135 | 135 | * @param string $data |
| 136 | 136 | * @return int |
| 137 | 137 | */ |
| 138 | - public function prepend($path, $data) |
|
| 138 | + public function prepend( $path, $data ) |
|
| 139 | 139 | { |
| 140 | - if ($this->exists($path)) { |
|
| 141 | - return $this->put($path, $data.$this->get($path)); |
|
| 140 | + if ( $this->exists( $path ) ) { |
|
| 141 | + return $this->put( $path, $data . $this->get( $path ) ); |
|
| 142 | 142 | } |
| 143 | 143 | |
| 144 | - return $this->put($path, $data); |
|
| 144 | + return $this->put( $path, $data ); |
|
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | /** |
@@ -151,9 +151,9 @@ discard block |
||
| 151 | 151 | * @param string $data |
| 152 | 152 | * @return int |
| 153 | 153 | */ |
| 154 | - public function append($path, $data) |
|
| 154 | + public function append( $path, $data ) |
|
| 155 | 155 | { |
| 156 | - return file_put_contents($path, $data, FILE_APPEND); |
|
| 156 | + return file_put_contents( $path, $data, FILE_APPEND ); |
|
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | /** |
@@ -163,13 +163,13 @@ discard block |
||
| 163 | 163 | * @param int $mode |
| 164 | 164 | * @return mixed |
| 165 | 165 | */ |
| 166 | - public function chmod($path, $mode = null) |
|
| 166 | + public function chmod( $path, $mode = null ) |
|
| 167 | 167 | { |
| 168 | - if ($mode) { |
|
| 169 | - return chmod($path, $mode); |
|
| 168 | + if ( $mode ) { |
|
| 169 | + return chmod( $path, $mode ); |
|
| 170 | 170 | } |
| 171 | 171 | |
| 172 | - return substr(sprintf('%o', fileperms($path)), -4); |
|
| 172 | + return substr( sprintf( '%o', fileperms( $path ) ), -4 ); |
|
| 173 | 173 | } |
| 174 | 174 | |
| 175 | 175 | /** |
@@ -178,18 +178,18 @@ discard block |
||
| 178 | 178 | * @param string|array $paths |
| 179 | 179 | * @return bool |
| 180 | 180 | */ |
| 181 | - public function delete($paths) |
|
| 181 | + public function delete( $paths ) |
|
| 182 | 182 | { |
| 183 | - $paths = is_array($paths) ? $paths : func_get_args(); |
|
| 183 | + $paths = is_array( $paths ) ? $paths : func_get_args(); |
|
| 184 | 184 | |
| 185 | 185 | $success = true; |
| 186 | 186 | |
| 187 | - foreach ($paths as $path) { |
|
| 187 | + foreach ( $paths as $path ) { |
|
| 188 | 188 | try { |
| 189 | - if (! @unlink($path)) { |
|
| 189 | + if ( ! @unlink( $path ) ) { |
|
| 190 | 190 | $success = false; |
| 191 | 191 | } |
| 192 | - } catch (ErrorException $e) { |
|
| 192 | + } catch ( ErrorException $e ) { |
|
| 193 | 193 | $success = false; |
| 194 | 194 | } |
| 195 | 195 | } |
@@ -204,9 +204,9 @@ discard block |
||
| 204 | 204 | * @param string $target |
| 205 | 205 | * @return bool |
| 206 | 206 | */ |
| 207 | - public function move($path, $target) |
|
| 207 | + public function move( $path, $target ) |
|
| 208 | 208 | { |
| 209 | - return rename($path, $target); |
|
| 209 | + return rename( $path, $target ); |
|
| 210 | 210 | } |
| 211 | 211 | |
| 212 | 212 | /** |
@@ -216,9 +216,9 @@ discard block |
||
| 216 | 216 | * @param string $target |
| 217 | 217 | * @return bool |
| 218 | 218 | */ |
| 219 | - public function copy($path, $target) |
|
| 219 | + public function copy( $path, $target ) |
|
| 220 | 220 | { |
| 221 | - return copy($path, $target); |
|
| 221 | + return copy( $path, $target ); |
|
| 222 | 222 | } |
| 223 | 223 | |
| 224 | 224 | /** |
@@ -228,15 +228,15 @@ discard block |
||
| 228 | 228 | * @param string $link |
| 229 | 229 | * @return void |
| 230 | 230 | */ |
| 231 | - public function link($target, $link) |
|
| 231 | + public function link( $target, $link ) |
|
| 232 | 232 | { |
| 233 | - if (! windows_os()) { |
|
| 234 | - return symlink($target, $link); |
|
| 233 | + if ( ! windows_os() ) { |
|
| 234 | + return symlink( $target, $link ); |
|
| 235 | 235 | } |
| 236 | 236 | |
| 237 | - $mode = $this->isDirectory($target) ? 'J' : 'H'; |
|
| 237 | + $mode = $this->isDirectory( $target ) ? 'J' : 'H'; |
|
| 238 | 238 | |
| 239 | - exec("mklink /{$mode} \"{$link}\" \"{$target}\""); |
|
| 239 | + exec( "mklink /{$mode} \"{$link}\" \"{$target}\"" ); |
|
| 240 | 240 | } |
| 241 | 241 | |
| 242 | 242 | /** |
@@ -245,9 +245,9 @@ discard block |
||
| 245 | 245 | * @param string $path |
| 246 | 246 | * @return string |
| 247 | 247 | */ |
| 248 | - public function name($path) |
|
| 248 | + public function name( $path ) |
|
| 249 | 249 | { |
| 250 | - return pathinfo($path, PATHINFO_FILENAME); |
|
| 250 | + return pathinfo( $path, PATHINFO_FILENAME ); |
|
| 251 | 251 | } |
| 252 | 252 | |
| 253 | 253 | /** |
@@ -256,9 +256,9 @@ discard block |
||
| 256 | 256 | * @param string $path |
| 257 | 257 | * @return string |
| 258 | 258 | */ |
| 259 | - public function basename($path) |
|
| 259 | + public function basename( $path ) |
|
| 260 | 260 | { |
| 261 | - return pathinfo($path, PATHINFO_BASENAME); |
|
| 261 | + return pathinfo( $path, PATHINFO_BASENAME ); |
|
| 262 | 262 | } |
| 263 | 263 | |
| 264 | 264 | /** |
@@ -267,9 +267,9 @@ discard block |
||
| 267 | 267 | * @param string $path |
| 268 | 268 | * @return string |
| 269 | 269 | */ |
| 270 | - public function dirname($path) |
|
| 270 | + public function dirname( $path ) |
|
| 271 | 271 | { |
| 272 | - return pathinfo($path, PATHINFO_DIRNAME); |
|
| 272 | + return pathinfo( $path, PATHINFO_DIRNAME ); |
|
| 273 | 273 | } |
| 274 | 274 | |
| 275 | 275 | /** |
@@ -278,9 +278,9 @@ discard block |
||
| 278 | 278 | * @param string $path |
| 279 | 279 | * @return string |
| 280 | 280 | */ |
| 281 | - public function extension($path) |
|
| 281 | + public function extension( $path ) |
|
| 282 | 282 | { |
| 283 | - return pathinfo($path, PATHINFO_EXTENSION); |
|
| 283 | + return pathinfo( $path, PATHINFO_EXTENSION ); |
|
| 284 | 284 | } |
| 285 | 285 | |
| 286 | 286 | /** |
@@ -289,9 +289,9 @@ discard block |
||
| 289 | 289 | * @param string $path |
| 290 | 290 | * @return string |
| 291 | 291 | */ |
| 292 | - public function type($path) |
|
| 292 | + public function type( $path ) |
|
| 293 | 293 | { |
| 294 | - return filetype($path); |
|
| 294 | + return filetype( $path ); |
|
| 295 | 295 | } |
| 296 | 296 | |
| 297 | 297 | /** |
@@ -300,9 +300,9 @@ discard block |
||
| 300 | 300 | * @param string $path |
| 301 | 301 | * @return string|false |
| 302 | 302 | */ |
| 303 | - public function mimeType($path) |
|
| 303 | + public function mimeType( $path ) |
|
| 304 | 304 | { |
| 305 | - return finfo_file(finfo_open(FILEINFO_MIME_TYPE), $path); |
|
| 305 | + return finfo_file( finfo_open( FILEINFO_MIME_TYPE ), $path ); |
|
| 306 | 306 | } |
| 307 | 307 | |
| 308 | 308 | /** |
@@ -311,9 +311,9 @@ discard block |
||
| 311 | 311 | * @param string $path |
| 312 | 312 | * @return int |
| 313 | 313 | */ |
| 314 | - public function size($path) |
|
| 314 | + public function size( $path ) |
|
| 315 | 315 | { |
| 316 | - return filesize($path); |
|
| 316 | + return filesize( $path ); |
|
| 317 | 317 | } |
| 318 | 318 | |
| 319 | 319 | /** |
@@ -322,9 +322,9 @@ discard block |
||
| 322 | 322 | * @param string $path |
| 323 | 323 | * @return int |
| 324 | 324 | */ |
| 325 | - public function lastModified($path) |
|
| 325 | + public function lastModified( $path ) |
|
| 326 | 326 | { |
| 327 | - return filemtime($path); |
|
| 327 | + return filemtime( $path ); |
|
| 328 | 328 | } |
| 329 | 329 | |
| 330 | 330 | /** |
@@ -333,9 +333,9 @@ discard block |
||
| 333 | 333 | * @param string $directory |
| 334 | 334 | * @return bool |
| 335 | 335 | */ |
| 336 | - public function isDirectory($directory) |
|
| 336 | + public function isDirectory( $directory ) |
|
| 337 | 337 | { |
| 338 | - return is_dir($directory); |
|
| 338 | + return is_dir( $directory ); |
|
| 339 | 339 | } |
| 340 | 340 | |
| 341 | 341 | /** |
@@ -344,9 +344,9 @@ discard block |
||
| 344 | 344 | * @param string $path |
| 345 | 345 | * @return bool |
| 346 | 346 | */ |
| 347 | - public function isReadable($path) |
|
| 347 | + public function isReadable( $path ) |
|
| 348 | 348 | { |
| 349 | - return is_readable($path); |
|
| 349 | + return is_readable( $path ); |
|
| 350 | 350 | } |
| 351 | 351 | |
| 352 | 352 | /** |
@@ -355,9 +355,9 @@ discard block |
||
| 355 | 355 | * @param string $path |
| 356 | 356 | * @return bool |
| 357 | 357 | */ |
| 358 | - public function isWritable($path) |
|
| 358 | + public function isWritable( $path ) |
|
| 359 | 359 | { |
| 360 | - return is_writable($path); |
|
| 360 | + return is_writable( $path ); |
|
| 361 | 361 | } |
| 362 | 362 | |
| 363 | 363 | /** |
@@ -366,9 +366,9 @@ discard block |
||
| 366 | 366 | * @param string $file |
| 367 | 367 | * @return bool |
| 368 | 368 | */ |
| 369 | - public function isFile($file) |
|
| 369 | + public function isFile( $file ) |
|
| 370 | 370 | { |
| 371 | - return is_file($file); |
|
| 371 | + return is_file( $file ); |
|
| 372 | 372 | } |
| 373 | 373 | |
| 374 | 374 | /** |
@@ -378,9 +378,9 @@ discard block |
||
| 378 | 378 | * @param int $flags |
| 379 | 379 | * @return array |
| 380 | 380 | */ |
| 381 | - public function glob($pattern, $flags = 0) |
|
| 381 | + public function glob( $pattern, $flags = 0 ) |
|
| 382 | 382 | { |
| 383 | - return glob($pattern, $flags); |
|
| 383 | + return glob( $pattern, $flags ); |
|
| 384 | 384 | } |
| 385 | 385 | |
| 386 | 386 | /** |
@@ -389,19 +389,19 @@ discard block |
||
| 389 | 389 | * @param string $directory |
| 390 | 390 | * @return array |
| 391 | 391 | */ |
| 392 | - public function files($directory) |
|
| 392 | + public function files( $directory ) |
|
| 393 | 393 | { |
| 394 | - $glob = glob($directory.DIRECTORY_SEPARATOR.'*'); |
|
| 394 | + $glob = glob( $directory . DIRECTORY_SEPARATOR . '*' ); |
|
| 395 | 395 | |
| 396 | - if ($glob === false) { |
|
| 397 | - return []; |
|
| 396 | + if ( $glob === false ) { |
|
| 397 | + return [ ]; |
|
| 398 | 398 | } |
| 399 | 399 | |
| 400 | 400 | // To get the appropriate files, we'll simply glob the directory and filter |
| 401 | 401 | // out any "files" that are not truly files so we do not end up with any |
| 402 | 402 | // directories in our list, but only true files within the directory. |
| 403 | - return array_filter($glob, function ($file) { |
|
| 404 | - return filetype($file) == 'file'; |
|
| 403 | + return array_filter( $glob, function( $file ) { |
|
| 404 | + return filetype( $file ) == 'file'; |
|
| 405 | 405 | }); |
| 406 | 406 | } |
| 407 | 407 | |
@@ -412,9 +412,9 @@ discard block |
||
| 412 | 412 | * @param bool $hidden |
| 413 | 413 | * @return array |
| 414 | 414 | */ |
| 415 | - public function allFiles($directory, $hidden = false) |
|
| 415 | + public function allFiles( $directory, $hidden = false ) |
|
| 416 | 416 | { |
| 417 | - return iterator_to_array(Finder::create()->files()->ignoreDotFiles(! $hidden)->in($directory), false); |
|
| 417 | + return iterator_to_array( Finder::create()->files()->ignoreDotFiles( ! $hidden )->in( $directory ), false ); |
|
| 418 | 418 | } |
| 419 | 419 | |
| 420 | 420 | /** |
@@ -423,12 +423,12 @@ discard block |
||
| 423 | 423 | * @param string $directory |
| 424 | 424 | * @return array |
| 425 | 425 | */ |
| 426 | - public function directories($directory) |
|
| 426 | + public function directories( $directory ) |
|
| 427 | 427 | { |
| 428 | - $directories = []; |
|
| 428 | + $directories = [ ]; |
|
| 429 | 429 | |
| 430 | - foreach (Finder::create()->in($directory)->directories()->depth(0) as $dir) { |
|
| 431 | - $directories[] = $dir->getPathname(); |
|
| 430 | + foreach ( Finder::create()->in( $directory )->directories()->depth( 0 ) as $dir ) { |
|
| 431 | + $directories[ ] = $dir->getPathname(); |
|
| 432 | 432 | } |
| 433 | 433 | |
| 434 | 434 | return $directories; |
@@ -443,13 +443,13 @@ discard block |
||
| 443 | 443 | * @param bool $force |
| 444 | 444 | * @return bool |
| 445 | 445 | */ |
| 446 | - public function makeDirectory($path, $mode = 0755, $recursive = false, $force = false) |
|
| 446 | + public function makeDirectory( $path, $mode = 0755, $recursive = false, $force = false ) |
|
| 447 | 447 | { |
| 448 | - if ($force) { |
|
| 449 | - return @mkdir($path, $mode, $recursive); |
|
| 448 | + if ( $force ) { |
|
| 449 | + return @mkdir( $path, $mode, $recursive ); |
|
| 450 | 450 | } |
| 451 | 451 | |
| 452 | - return mkdir($path, $mode, $recursive); |
|
| 452 | + return mkdir( $path, $mode, $recursive ); |
|
| 453 | 453 | } |
| 454 | 454 | |
| 455 | 455 | /** |
@@ -460,15 +460,15 @@ discard block |
||
| 460 | 460 | * @param bool $overwrite |
| 461 | 461 | * @return bool |
| 462 | 462 | */ |
| 463 | - public function moveDirectory($from, $to, $overwrite = false) |
|
| 463 | + public function moveDirectory( $from, $to, $overwrite = false ) |
|
| 464 | 464 | { |
| 465 | - if ($overwrite && $this->isDirectory($to)) { |
|
| 466 | - if (! $this->deleteDirectory($to)) { |
|
| 465 | + if ( $overwrite && $this->isDirectory( $to ) ) { |
|
| 466 | + if ( ! $this->deleteDirectory( $to ) ) { |
|
| 467 | 467 | return false; |
| 468 | 468 | } |
| 469 | 469 | } |
| 470 | 470 | |
| 471 | - return @rename($from, $to) === true; |
|
| 471 | + return @rename( $from, $to ) === true; |
|
| 472 | 472 | } |
| 473 | 473 | |
| 474 | 474 | /** |
@@ -479,9 +479,9 @@ discard block |
||
| 479 | 479 | * @param int $options |
| 480 | 480 | * @return bool |
| 481 | 481 | */ |
| 482 | - public function copyDirectory($directory, $destination, $options = null) |
|
| 482 | + public function copyDirectory( $directory, $destination, $options = null ) |
|
| 483 | 483 | { |
| 484 | - if (! $this->isDirectory($directory)) { |
|
| 484 | + if ( ! $this->isDirectory( $directory ) ) { |
|
| 485 | 485 | return false; |
| 486 | 486 | } |
| 487 | 487 | |
@@ -490,22 +490,22 @@ discard block |
||
| 490 | 490 | // If the destination directory does not actually exist, we will go ahead and |
| 491 | 491 | // create it recursively, which just gets the destination prepared to copy |
| 492 | 492 | // the files over. Once we make the directory we'll proceed the copying. |
| 493 | - if (! $this->isDirectory($destination)) { |
|
| 494 | - $this->makeDirectory($destination, 0777, true); |
|
| 493 | + if ( ! $this->isDirectory( $destination ) ) { |
|
| 494 | + $this->makeDirectory( $destination, 0777, true ); |
|
| 495 | 495 | } |
| 496 | 496 | |
| 497 | - $items = new FilesystemIterator($directory, $options); |
|
| 497 | + $items = new FilesystemIterator( $directory, $options ); |
|
| 498 | 498 | |
| 499 | - foreach ($items as $item) { |
|
| 499 | + foreach ( $items as $item ) { |
|
| 500 | 500 | // As we spin through items, we will check to see if the current file is actually |
| 501 | 501 | // a directory or a file. When it is actually a directory we will need to call |
| 502 | 502 | // back into this function recursively to keep copying these nested folders. |
| 503 | - $target = $destination.'/'.$item->getBasename(); |
|
| 503 | + $target = $destination . '/' . $item->getBasename(); |
|
| 504 | 504 | |
| 505 | - if ($item->isDir()) { |
|
| 505 | + if ( $item->isDir() ) { |
|
| 506 | 506 | $path = $item->getPathname(); |
| 507 | 507 | |
| 508 | - if (! $this->copyDirectory($path, $target, $options)) { |
|
| 508 | + if ( ! $this->copyDirectory( $path, $target, $options ) ) { |
|
| 509 | 509 | return false; |
| 510 | 510 | } |
| 511 | 511 | } |
@@ -514,7 +514,7 @@ discard block |
||
| 514 | 514 | // location and keep looping. If for some reason the copy fails we'll bail out |
| 515 | 515 | // and return false, so the developer is aware that the copy process failed. |
| 516 | 516 | else { |
| 517 | - if (! $this->copy($item->getPathname(), $target)) { |
|
| 517 | + if ( ! $this->copy( $item->getPathname(), $target ) ) { |
|
| 518 | 518 | return false; |
| 519 | 519 | } |
| 520 | 520 | } |
@@ -532,32 +532,32 @@ discard block |
||
| 532 | 532 | * @param bool $preserve |
| 533 | 533 | * @return bool |
| 534 | 534 | */ |
| 535 | - public function deleteDirectory($directory, $preserve = false) |
|
| 535 | + public function deleteDirectory( $directory, $preserve = false ) |
|
| 536 | 536 | { |
| 537 | - if (! $this->isDirectory($directory)) { |
|
| 537 | + if ( ! $this->isDirectory( $directory ) ) { |
|
| 538 | 538 | return false; |
| 539 | 539 | } |
| 540 | 540 | |
| 541 | - $items = new FilesystemIterator($directory); |
|
| 541 | + $items = new FilesystemIterator( $directory ); |
|
| 542 | 542 | |
| 543 | - foreach ($items as $item) { |
|
| 543 | + foreach ( $items as $item ) { |
|
| 544 | 544 | // If the item is a directory, we can just recurse into the function and |
| 545 | 545 | // delete that sub-directory otherwise we'll just delete the file and |
| 546 | 546 | // keep iterating through each file until the directory is cleaned. |
| 547 | - if ($item->isDir() && ! $item->isLink()) { |
|
| 548 | - $this->deleteDirectory($item->getPathname()); |
|
| 547 | + if ( $item->isDir() && ! $item->isLink() ) { |
|
| 548 | + $this->deleteDirectory( $item->getPathname() ); |
|
| 549 | 549 | } |
| 550 | 550 | |
| 551 | 551 | // If the item is just a file, we can go ahead and delete it since we're |
| 552 | 552 | // just looping through and waxing all of the files in this directory |
| 553 | 553 | // and calling directories recursively, so we delete the real path. |
| 554 | 554 | else { |
| 555 | - $this->delete($item->getPathname()); |
|
| 555 | + $this->delete( $item->getPathname() ); |
|
| 556 | 556 | } |
| 557 | 557 | } |
| 558 | 558 | |
| 559 | - if (! $preserve) { |
|
| 560 | - @rmdir($directory); |
|
| 559 | + if ( ! $preserve ) { |
|
| 560 | + @rmdir( $directory ); |
|
| 561 | 561 | } |
| 562 | 562 | |
| 563 | 563 | return true; |
@@ -569,8 +569,8 @@ discard block |
||
| 569 | 569 | * @param string $directory |
| 570 | 570 | * @return bool |
| 571 | 571 | */ |
| 572 | - public function cleanDirectory($directory) |
|
| 572 | + public function cleanDirectory( $directory ) |
|
| 573 | 573 | { |
| 574 | - return $this->deleteDirectory($directory, true); |
|
| 574 | + return $this->deleteDirectory( $directory, true ); |
|
| 575 | 575 | } |
| 576 | 576 | } |
@@ -30,112 +30,112 @@ discard block |
||
| 30 | 30 | * |
| 31 | 31 | * @var array |
| 32 | 32 | */ |
| 33 | - protected $resolved = []; |
|
| 33 | + protected $resolved = [ ]; |
|
| 34 | 34 | |
| 35 | 35 | /** |
| 36 | 36 | * The container's bindings. |
| 37 | 37 | * |
| 38 | 38 | * @var array |
| 39 | 39 | */ |
| 40 | - protected $bindings = []; |
|
| 40 | + protected $bindings = [ ]; |
|
| 41 | 41 | |
| 42 | 42 | /** |
| 43 | 43 | * The container's method bindings. |
| 44 | 44 | * |
| 45 | 45 | * @var array |
| 46 | 46 | */ |
| 47 | - protected $methodBindings = []; |
|
| 47 | + protected $methodBindings = [ ]; |
|
| 48 | 48 | |
| 49 | 49 | /** |
| 50 | 50 | * The container's shared instances. |
| 51 | 51 | * |
| 52 | 52 | * @var array |
| 53 | 53 | */ |
| 54 | - protected $instances = []; |
|
| 54 | + protected $instances = [ ]; |
|
| 55 | 55 | |
| 56 | 56 | /** |
| 57 | 57 | * The registered type aliases. |
| 58 | 58 | * |
| 59 | 59 | * @var array |
| 60 | 60 | */ |
| 61 | - protected $aliases = []; |
|
| 61 | + protected $aliases = [ ]; |
|
| 62 | 62 | |
| 63 | 63 | /** |
| 64 | 64 | * The registered aliases keyed by the abstract name. |
| 65 | 65 | * |
| 66 | 66 | * @var array |
| 67 | 67 | */ |
| 68 | - protected $abstractAliases = []; |
|
| 68 | + protected $abstractAliases = [ ]; |
|
| 69 | 69 | |
| 70 | 70 | /** |
| 71 | 71 | * The extension closures for services. |
| 72 | 72 | * |
| 73 | 73 | * @var array |
| 74 | 74 | */ |
| 75 | - protected $extenders = []; |
|
| 75 | + protected $extenders = [ ]; |
|
| 76 | 76 | |
| 77 | 77 | /** |
| 78 | 78 | * All of the registered tags. |
| 79 | 79 | * |
| 80 | 80 | * @var array |
| 81 | 81 | */ |
| 82 | - protected $tags = []; |
|
| 82 | + protected $tags = [ ]; |
|
| 83 | 83 | |
| 84 | 84 | /** |
| 85 | 85 | * The stack of concretions currently being built. |
| 86 | 86 | * |
| 87 | 87 | * @var array |
| 88 | 88 | */ |
| 89 | - protected $buildStack = []; |
|
| 89 | + protected $buildStack = [ ]; |
|
| 90 | 90 | |
| 91 | 91 | /** |
| 92 | 92 | * The parameter override stack. |
| 93 | 93 | * |
| 94 | 94 | * @var array |
| 95 | 95 | */ |
| 96 | - protected $with = []; |
|
| 96 | + protected $with = [ ]; |
|
| 97 | 97 | |
| 98 | 98 | /** |
| 99 | 99 | * The contextual binding map. |
| 100 | 100 | * |
| 101 | 101 | * @var array |
| 102 | 102 | */ |
| 103 | - public $contextual = []; |
|
| 103 | + public $contextual = [ ]; |
|
| 104 | 104 | |
| 105 | 105 | /** |
| 106 | 106 | * All of the registered rebound callbacks. |
| 107 | 107 | * |
| 108 | 108 | * @var array |
| 109 | 109 | */ |
| 110 | - protected $reboundCallbacks = []; |
|
| 110 | + protected $reboundCallbacks = [ ]; |
|
| 111 | 111 | |
| 112 | 112 | /** |
| 113 | 113 | * All of the global resolving callbacks. |
| 114 | 114 | * |
| 115 | 115 | * @var array |
| 116 | 116 | */ |
| 117 | - protected $globalResolvingCallbacks = []; |
|
| 117 | + protected $globalResolvingCallbacks = [ ]; |
|
| 118 | 118 | |
| 119 | 119 | /** |
| 120 | 120 | * All of the global after resolving callbacks. |
| 121 | 121 | * |
| 122 | 122 | * @var array |
| 123 | 123 | */ |
| 124 | - protected $globalAfterResolvingCallbacks = []; |
|
| 124 | + protected $globalAfterResolvingCallbacks = [ ]; |
|
| 125 | 125 | |
| 126 | 126 | /** |
| 127 | 127 | * All of the resolving callbacks by class type. |
| 128 | 128 | * |
| 129 | 129 | * @var array |
| 130 | 130 | */ |
| 131 | - protected $resolvingCallbacks = []; |
|
| 131 | + protected $resolvingCallbacks = [ ]; |
|
| 132 | 132 | |
| 133 | 133 | /** |
| 134 | 134 | * All of the after resolving callbacks by class type. |
| 135 | 135 | * |
| 136 | 136 | * @var array |
| 137 | 137 | */ |
| 138 | - protected $afterResolvingCallbacks = []; |
|
| 138 | + protected $afterResolvingCallbacks = [ ]; |
|
| 139 | 139 | |
| 140 | 140 | /** |
| 141 | 141 | * Define a contextual binding. |
@@ -143,9 +143,9 @@ discard block |
||
| 143 | 143 | * @param string $concrete |
| 144 | 144 | * @return \GravityKit\GravityView\Foundation\ThirdParty\Illuminate\Contracts\Container\ContextualBindingBuilder |
| 145 | 145 | */ |
| 146 | - public function when($concrete) |
|
| 146 | + public function when( $concrete ) |
|
| 147 | 147 | { |
| 148 | - return new ContextualBindingBuilder($this, $this->getAlias($concrete)); |
|
| 148 | + return new ContextualBindingBuilder( $this, $this->getAlias( $concrete ) ); |
|
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | /** |
@@ -154,11 +154,11 @@ discard block |
||
| 154 | 154 | * @param string $abstract |
| 155 | 155 | * @return bool |
| 156 | 156 | */ |
| 157 | - public function bound($abstract) |
|
| 157 | + public function bound( $abstract ) |
|
| 158 | 158 | { |
| 159 | - return isset($this->bindings[$abstract]) || |
|
| 160 | - isset($this->instances[$abstract]) || |
|
| 161 | - $this->isAlias($abstract); |
|
| 159 | + return isset( $this->bindings[ $abstract ] ) || |
|
| 160 | + isset( $this->instances[ $abstract ] ) || |
|
| 161 | + $this->isAlias( $abstract ); |
|
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | /** |
@@ -167,14 +167,14 @@ discard block |
||
| 167 | 167 | * @param string $abstract |
| 168 | 168 | * @return bool |
| 169 | 169 | */ |
| 170 | - public function resolved($abstract) |
|
| 170 | + public function resolved( $abstract ) |
|
| 171 | 171 | { |
| 172 | - if ($this->isAlias($abstract)) { |
|
| 173 | - $abstract = $this->getAlias($abstract); |
|
| 172 | + if ( $this->isAlias( $abstract ) ) { |
|
| 173 | + $abstract = $this->getAlias( $abstract ); |
|
| 174 | 174 | } |
| 175 | 175 | |
| 176 | - return isset($this->resolved[$abstract]) || |
|
| 177 | - isset($this->instances[$abstract]); |
|
| 176 | + return isset( $this->resolved[ $abstract ] ) || |
|
| 177 | + isset( $this->instances[ $abstract ] ); |
|
| 178 | 178 | } |
| 179 | 179 | |
| 180 | 180 | /** |
@@ -183,11 +183,11 @@ discard block |
||
| 183 | 183 | * @param string $abstract |
| 184 | 184 | * @return bool |
| 185 | 185 | */ |
| 186 | - public function isShared($abstract) |
|
| 186 | + public function isShared( $abstract ) |
|
| 187 | 187 | { |
| 188 | - return isset($this->instances[$abstract]) || |
|
| 189 | - (isset($this->bindings[$abstract]['shared']) && |
|
| 190 | - $this->bindings[$abstract]['shared'] === true); |
|
| 188 | + return isset( $this->instances[ $abstract ] ) || |
|
| 189 | + ( isset( $this->bindings[ $abstract ][ 'shared' ] ) && |
|
| 190 | + $this->bindings[ $abstract ][ 'shared' ] === true ); |
|
| 191 | 191 | } |
| 192 | 192 | |
| 193 | 193 | /** |
@@ -196,9 +196,9 @@ discard block |
||
| 196 | 196 | * @param string $name |
| 197 | 197 | * @return bool |
| 198 | 198 | */ |
| 199 | - public function isAlias($name) |
|
| 199 | + public function isAlias( $name ) |
|
| 200 | 200 | { |
| 201 | - return isset($this->aliases[$name]); |
|
| 201 | + return isset( $this->aliases[ $name ] ); |
|
| 202 | 202 | } |
| 203 | 203 | |
| 204 | 204 | /** |
@@ -209,31 +209,31 @@ discard block |
||
| 209 | 209 | * @param bool $shared |
| 210 | 210 | * @return void |
| 211 | 211 | */ |
| 212 | - public function bind($abstract, $concrete = null, $shared = false) |
|
| 212 | + public function bind( $abstract, $concrete = null, $shared = false ) |
|
| 213 | 213 | { |
| 214 | 214 | // If no concrete type was given, we will simply set the concrete type to the |
| 215 | 215 | // abstract type. After that, the concrete type to be registered as shared |
| 216 | 216 | // without being forced to state their classes in both of the parameters. |
| 217 | - $this->dropStaleInstances($abstract); |
|
| 217 | + $this->dropStaleInstances( $abstract ); |
|
| 218 | 218 | |
| 219 | - if (is_null($concrete)) { |
|
| 219 | + if ( is_null( $concrete ) ) { |
|
| 220 | 220 | $concrete = $abstract; |
| 221 | 221 | } |
| 222 | 222 | |
| 223 | 223 | // If the factory is not a Closure, it means it is just a class name which is |
| 224 | 224 | // bound into this container to the abstract type and we will just wrap it |
| 225 | 225 | // up inside its own Closure to give us more convenience when extending. |
| 226 | - if (! $concrete instanceof Closure) { |
|
| 227 | - $concrete = $this->getClosure($abstract, $concrete); |
|
| 226 | + if ( ! $concrete instanceof Closure ) { |
|
| 227 | + $concrete = $this->getClosure( $abstract, $concrete ); |
|
| 228 | 228 | } |
| 229 | 229 | |
| 230 | - $this->bindings[$abstract] = compact('concrete', 'shared'); |
|
| 230 | + $this->bindings[ $abstract ] = compact( 'concrete', 'shared' ); |
|
| 231 | 231 | |
| 232 | 232 | // If the abstract type was already resolved in this container we'll fire the |
| 233 | 233 | // rebound listener so that any objects which have already gotten resolved |
| 234 | 234 | // can have their copy of the object updated via the listener callbacks. |
| 235 | - if ($this->resolved($abstract)) { |
|
| 236 | - $this->rebound($abstract); |
|
| 235 | + if ( $this->resolved( $abstract ) ) { |
|
| 236 | + $this->rebound( $abstract ); |
|
| 237 | 237 | } |
| 238 | 238 | } |
| 239 | 239 | |
@@ -244,14 +244,14 @@ discard block |
||
| 244 | 244 | * @param string $concrete |
| 245 | 245 | * @return \Closure |
| 246 | 246 | */ |
| 247 | - protected function getClosure($abstract, $concrete) |
|
| 247 | + protected function getClosure( $abstract, $concrete ) |
|
| 248 | 248 | { |
| 249 | - return function ($container, $parameters = []) use ($abstract, $concrete) { |
|
| 250 | - if ($abstract == $concrete) { |
|
| 251 | - return $container->build($concrete); |
|
| 249 | + return function( $container, $parameters = [ ] ) use ( $abstract, $concrete ) { |
|
| 250 | + if ( $abstract == $concrete ) { |
|
| 251 | + return $container->build( $concrete ); |
|
| 252 | 252 | } |
| 253 | 253 | |
| 254 | - return $container->makeWith($concrete, $parameters); |
|
| 254 | + return $container->makeWith( $concrete, $parameters ); |
|
| 255 | 255 | }; |
| 256 | 256 | } |
| 257 | 257 | |
@@ -261,9 +261,9 @@ discard block |
||
| 261 | 261 | * @param string $method |
| 262 | 262 | * @return bool |
| 263 | 263 | */ |
| 264 | - public function hasMethodBinding($method) |
|
| 264 | + public function hasMethodBinding( $method ) |
|
| 265 | 265 | { |
| 266 | - return isset($this->methodBindings[$method]); |
|
| 266 | + return isset( $this->methodBindings[ $method ] ); |
|
| 267 | 267 | } |
| 268 | 268 | |
| 269 | 269 | /** |
@@ -273,9 +273,9 @@ discard block |
||
| 273 | 273 | * @param \Closure $callback |
| 274 | 274 | * @return void |
| 275 | 275 | */ |
| 276 | - public function bindMethod($method, $callback) |
|
| 276 | + public function bindMethod( $method, $callback ) |
|
| 277 | 277 | { |
| 278 | - $this->methodBindings[$method] = $callback; |
|
| 278 | + $this->methodBindings[ $method ] = $callback; |
|
| 279 | 279 | } |
| 280 | 280 | |
| 281 | 281 | /** |
@@ -285,9 +285,9 @@ discard block |
||
| 285 | 285 | * @param mixed $instance |
| 286 | 286 | * @return mixed |
| 287 | 287 | */ |
| 288 | - public function callMethodBinding($method, $instance) |
|
| 288 | + public function callMethodBinding( $method, $instance ) |
|
| 289 | 289 | { |
| 290 | - return call_user_func($this->methodBindings[$method], $instance, $this); |
|
| 290 | + return call_user_func( $this->methodBindings[ $method ], $instance, $this ); |
|
| 291 | 291 | } |
| 292 | 292 | |
| 293 | 293 | /** |
@@ -298,9 +298,9 @@ discard block |
||
| 298 | 298 | * @param \Closure|string $implementation |
| 299 | 299 | * @return void |
| 300 | 300 | */ |
| 301 | - public function addContextualBinding($concrete, $abstract, $implementation) |
|
| 301 | + public function addContextualBinding( $concrete, $abstract, $implementation ) |
|
| 302 | 302 | { |
| 303 | - $this->contextual[$concrete][$this->getAlias($abstract)] = $implementation; |
|
| 303 | + $this->contextual[ $concrete ][ $this->getAlias( $abstract ) ] = $implementation; |
|
| 304 | 304 | } |
| 305 | 305 | |
| 306 | 306 | /** |
@@ -311,10 +311,10 @@ discard block |
||
| 311 | 311 | * @param bool $shared |
| 312 | 312 | * @return void |
| 313 | 313 | */ |
| 314 | - public function bindIf($abstract, $concrete = null, $shared = false) |
|
| 314 | + public function bindIf( $abstract, $concrete = null, $shared = false ) |
|
| 315 | 315 | { |
| 316 | - if (! $this->bound($abstract)) { |
|
| 317 | - $this->bind($abstract, $concrete, $shared); |
|
| 316 | + if ( ! $this->bound( $abstract ) ) { |
|
| 317 | + $this->bind( $abstract, $concrete, $shared ); |
|
| 318 | 318 | } |
| 319 | 319 | } |
| 320 | 320 | |
@@ -325,9 +325,9 @@ discard block |
||
| 325 | 325 | * @param \Closure|string|null $concrete |
| 326 | 326 | * @return void |
| 327 | 327 | */ |
| 328 | - public function singleton($abstract, $concrete = null) |
|
| 328 | + public function singleton( $abstract, $concrete = null ) |
|
| 329 | 329 | { |
| 330 | - $this->bind($abstract, $concrete, true); |
|
| 330 | + $this->bind( $abstract, $concrete, true ); |
|
| 331 | 331 | } |
| 332 | 332 | |
| 333 | 333 | /** |
@@ -339,19 +339,19 @@ discard block |
||
| 339 | 339 | * |
| 340 | 340 | * @throws \InvalidArgumentException |
| 341 | 341 | */ |
| 342 | - public function extend($abstract, Closure $closure) |
|
| 342 | + public function extend( $abstract, Closure $closure ) |
|
| 343 | 343 | { |
| 344 | - $abstract = $this->getAlias($abstract); |
|
| 344 | + $abstract = $this->getAlias( $abstract ); |
|
| 345 | 345 | |
| 346 | - if (isset($this->instances[$abstract])) { |
|
| 347 | - $this->instances[$abstract] = $closure($this->instances[$abstract], $this); |
|
| 346 | + if ( isset( $this->instances[ $abstract ] ) ) { |
|
| 347 | + $this->instances[ $abstract ] = $closure( $this->instances[ $abstract ], $this ); |
|
| 348 | 348 | |
| 349 | - $this->rebound($abstract); |
|
| 349 | + $this->rebound( $abstract ); |
|
| 350 | 350 | } else { |
| 351 | - $this->extenders[$abstract][] = $closure; |
|
| 351 | + $this->extenders[ $abstract ][ ] = $closure; |
|
| 352 | 352 | |
| 353 | - if ($this->resolved($abstract)) { |
|
| 354 | - $this->rebound($abstract); |
|
| 353 | + if ( $this->resolved( $abstract ) ) { |
|
| 354 | + $this->rebound( $abstract ); |
|
| 355 | 355 | } |
| 356 | 356 | } |
| 357 | 357 | } |
@@ -363,21 +363,21 @@ discard block |
||
| 363 | 363 | * @param mixed $instance |
| 364 | 364 | * @return void |
| 365 | 365 | */ |
| 366 | - public function instance($abstract, $instance) |
|
| 366 | + public function instance( $abstract, $instance ) |
|
| 367 | 367 | { |
| 368 | - $this->removeAbstractAlias($abstract); |
|
| 368 | + $this->removeAbstractAlias( $abstract ); |
|
| 369 | 369 | |
| 370 | - $isBound = $this->bound($abstract); |
|
| 370 | + $isBound = $this->bound( $abstract ); |
|
| 371 | 371 | |
| 372 | - unset($this->aliases[$abstract]); |
|
| 372 | + unset( $this->aliases[ $abstract ] ); |
|
| 373 | 373 | |
| 374 | 374 | // We'll check to determine if this type has been bound before, and if it has |
| 375 | 375 | // we will fire the rebound callbacks registered with the container and it |
| 376 | 376 | // can be updated with consuming classes that have gotten resolved here. |
| 377 | - $this->instances[$abstract] = $instance; |
|
| 377 | + $this->instances[ $abstract ] = $instance; |
|
| 378 | 378 | |
| 379 | - if ($isBound) { |
|
| 380 | - $this->rebound($abstract); |
|
| 379 | + if ( $isBound ) { |
|
| 380 | + $this->rebound( $abstract ); |
|
| 381 | 381 | } |
| 382 | 382 | } |
| 383 | 383 | |
@@ -387,16 +387,16 @@ discard block |
||
| 387 | 387 | * @param string $searched |
| 388 | 388 | * @return void |
| 389 | 389 | */ |
| 390 | - protected function removeAbstractAlias($searched) |
|
| 390 | + protected function removeAbstractAlias( $searched ) |
|
| 391 | 391 | { |
| 392 | - if (! isset($this->aliases[$searched])) { |
|
| 392 | + if ( ! isset( $this->aliases[ $searched ] ) ) { |
|
| 393 | 393 | return; |
| 394 | 394 | } |
| 395 | 395 | |
| 396 | - foreach ($this->abstractAliases as $abstract => $aliases) { |
|
| 397 | - foreach ($aliases as $index => $alias) { |
|
| 398 | - if ($alias == $searched) { |
|
| 399 | - unset($this->abstractAliases[$abstract][$index]); |
|
| 396 | + foreach ( $this->abstractAliases as $abstract => $aliases ) { |
|
| 397 | + foreach ( $aliases as $index => $alias ) { |
|
| 398 | + if ( $alias == $searched ) { |
|
| 399 | + unset( $this->abstractAliases[ $abstract ][ $index ] ); |
|
| 400 | 400 | } |
| 401 | 401 | } |
| 402 | 402 | } |
@@ -409,17 +409,17 @@ discard block |
||
| 409 | 409 | * @param array|mixed ...$tags |
| 410 | 410 | * @return void |
| 411 | 411 | */ |
| 412 | - public function tag($abstracts, $tags) |
|
| 412 | + public function tag( $abstracts, $tags ) |
|
| 413 | 413 | { |
| 414 | - $tags = is_array($tags) ? $tags : array_slice(func_get_args(), 1); |
|
| 414 | + $tags = is_array( $tags ) ? $tags : array_slice( func_get_args(), 1 ); |
|
| 415 | 415 | |
| 416 | - foreach ($tags as $tag) { |
|
| 417 | - if (! isset($this->tags[$tag])) { |
|
| 418 | - $this->tags[$tag] = []; |
|
| 416 | + foreach ( $tags as $tag ) { |
|
| 417 | + if ( ! isset( $this->tags[ $tag ] ) ) { |
|
| 418 | + $this->tags[ $tag ] = [ ]; |
|
| 419 | 419 | } |
| 420 | 420 | |
| 421 | - foreach ((array) $abstracts as $abstract) { |
|
| 422 | - $this->tags[$tag][] = $abstract; |
|
| 421 | + foreach ( (array)$abstracts as $abstract ) { |
|
| 422 | + $this->tags[ $tag ][ ] = $abstract; |
|
| 423 | 423 | } |
| 424 | 424 | } |
| 425 | 425 | } |
@@ -430,13 +430,13 @@ discard block |
||
| 430 | 430 | * @param string $tag |
| 431 | 431 | * @return array |
| 432 | 432 | */ |
| 433 | - public function tagged($tag) |
|
| 433 | + public function tagged( $tag ) |
|
| 434 | 434 | { |
| 435 | - $results = []; |
|
| 435 | + $results = [ ]; |
|
| 436 | 436 | |
| 437 | - if (isset($this->tags[$tag])) { |
|
| 438 | - foreach ($this->tags[$tag] as $abstract) { |
|
| 439 | - $results[] = $this->make($abstract); |
|
| 437 | + if ( isset( $this->tags[ $tag ] ) ) { |
|
| 438 | + foreach ( $this->tags[ $tag ] as $abstract ) { |
|
| 439 | + $results[ ] = $this->make( $abstract ); |
|
| 440 | 440 | } |
| 441 | 441 | } |
| 442 | 442 | |
@@ -450,11 +450,11 @@ discard block |
||
| 450 | 450 | * @param string $alias |
| 451 | 451 | * @return void |
| 452 | 452 | */ |
| 453 | - public function alias($abstract, $alias) |
|
| 453 | + public function alias( $abstract, $alias ) |
|
| 454 | 454 | { |
| 455 | - $this->aliases[$alias] = $abstract; |
|
| 455 | + $this->aliases[ $alias ] = $abstract; |
|
| 456 | 456 | |
| 457 | - $this->abstractAliases[$abstract][] = $alias; |
|
| 457 | + $this->abstractAliases[ $abstract ][ ] = $alias; |
|
| 458 | 458 | } |
| 459 | 459 | |
| 460 | 460 | /** |
@@ -464,12 +464,12 @@ discard block |
||
| 464 | 464 | * @param \Closure $callback |
| 465 | 465 | * @return mixed |
| 466 | 466 | */ |
| 467 | - public function rebinding($abstract, Closure $callback) |
|
| 467 | + public function rebinding( $abstract, Closure $callback ) |
|
| 468 | 468 | { |
| 469 | - $this->reboundCallbacks[$abstract = $this->getAlias($abstract)][] = $callback; |
|
| 469 | + $this->reboundCallbacks[ $abstract = $this->getAlias( $abstract ) ][ ] = $callback; |
|
| 470 | 470 | |
| 471 | - if ($this->bound($abstract)) { |
|
| 472 | - return $this->make($abstract); |
|
| 471 | + if ( $this->bound( $abstract ) ) { |
|
| 472 | + return $this->make( $abstract ); |
|
| 473 | 473 | } |
| 474 | 474 | } |
| 475 | 475 | |
@@ -481,10 +481,10 @@ discard block |
||
| 481 | 481 | * @param string $method |
| 482 | 482 | * @return mixed |
| 483 | 483 | */ |
| 484 | - public function refresh($abstract, $target, $method) |
|
| 484 | + public function refresh( $abstract, $target, $method ) |
|
| 485 | 485 | { |
| 486 | - return $this->rebinding($abstract, function ($app, $instance) use ($target, $method) { |
|
| 487 | - $target->{$method}($instance); |
|
| 486 | + return $this->rebinding( $abstract, function( $app, $instance ) use ( $target, $method ) { |
|
| 487 | + $target->{$method}( $instance ); |
|
| 488 | 488 | }); |
| 489 | 489 | } |
| 490 | 490 | |
@@ -494,12 +494,12 @@ discard block |
||
| 494 | 494 | * @param string $abstract |
| 495 | 495 | * @return void |
| 496 | 496 | */ |
| 497 | - protected function rebound($abstract) |
|
| 497 | + protected function rebound( $abstract ) |
|
| 498 | 498 | { |
| 499 | - $instance = $this->make($abstract); |
|
| 499 | + $instance = $this->make( $abstract ); |
|
| 500 | 500 | |
| 501 | - foreach ($this->getReboundCallbacks($abstract) as $callback) { |
|
| 502 | - call_user_func($callback, $this, $instance); |
|
| 501 | + foreach ( $this->getReboundCallbacks( $abstract ) as $callback ) { |
|
| 502 | + call_user_func( $callback, $this, $instance ); |
|
| 503 | 503 | } |
| 504 | 504 | } |
| 505 | 505 | |
@@ -509,13 +509,13 @@ discard block |
||
| 509 | 509 | * @param string $abstract |
| 510 | 510 | * @return array |
| 511 | 511 | */ |
| 512 | - protected function getReboundCallbacks($abstract) |
|
| 512 | + protected function getReboundCallbacks( $abstract ) |
|
| 513 | 513 | { |
| 514 | - if (isset($this->reboundCallbacks[$abstract])) { |
|
| 515 | - return $this->reboundCallbacks[$abstract]; |
|
| 514 | + if ( isset( $this->reboundCallbacks[ $abstract ] ) ) { |
|
| 515 | + return $this->reboundCallbacks[ $abstract ]; |
|
| 516 | 516 | } |
| 517 | 517 | |
| 518 | - return []; |
|
| 518 | + return [ ]; |
|
| 519 | 519 | } |
| 520 | 520 | |
| 521 | 521 | /** |
@@ -525,10 +525,10 @@ discard block |
||
| 525 | 525 | * @param array $parameters |
| 526 | 526 | * @return \Closure |
| 527 | 527 | */ |
| 528 | - public function wrap(Closure $callback, array $parameters = []) |
|
| 528 | + public function wrap( Closure $callback, array $parameters = [ ] ) |
|
| 529 | 529 | { |
| 530 | - return function () use ($callback, $parameters) { |
|
| 531 | - return $this->call($callback, $parameters); |
|
| 530 | + return function() use ( $callback, $parameters ) { |
|
| 531 | + return $this->call( $callback, $parameters ); |
|
| 532 | 532 | }; |
| 533 | 533 | } |
| 534 | 534 | |
@@ -540,9 +540,9 @@ discard block |
||
| 540 | 540 | * @param string|null $defaultMethod |
| 541 | 541 | * @return mixed |
| 542 | 542 | */ |
| 543 | - public function call($callback, array $parameters = [], $defaultMethod = null) |
|
| 543 | + public function call( $callback, array $parameters = [ ], $defaultMethod = null ) |
|
| 544 | 544 | { |
| 545 | - return BoundMethod::call($this, $callback, $parameters, $defaultMethod); |
|
| 545 | + return BoundMethod::call( $this, $callback, $parameters, $defaultMethod ); |
|
| 546 | 546 | } |
| 547 | 547 | |
| 548 | 548 | /** |
@@ -551,10 +551,10 @@ discard block |
||
| 551 | 551 | * @param string $abstract |
| 552 | 552 | * @return \Closure |
| 553 | 553 | */ |
| 554 | - public function factory($abstract) |
|
| 554 | + public function factory( $abstract ) |
|
| 555 | 555 | { |
| 556 | - return function () use ($abstract) { |
|
| 557 | - return $this->make($abstract); |
|
| 556 | + return function() use ( $abstract ) { |
|
| 557 | + return $this->make( $abstract ); |
|
| 558 | 558 | }; |
| 559 | 559 | } |
| 560 | 560 | |
@@ -565,9 +565,9 @@ discard block |
||
| 565 | 565 | * @param array $parameters |
| 566 | 566 | * @return mixed |
| 567 | 567 | */ |
| 568 | - public function makeWith($abstract, array $parameters) |
|
| 568 | + public function makeWith( $abstract, array $parameters ) |
|
| 569 | 569 | { |
| 570 | - return $this->resolve($abstract, $parameters); |
|
| 570 | + return $this->resolve( $abstract, $parameters ); |
|
| 571 | 571 | } |
| 572 | 572 | |
| 573 | 573 | /** |
@@ -576,9 +576,9 @@ discard block |
||
| 576 | 576 | * @param string $abstract |
| 577 | 577 | * @return mixed |
| 578 | 578 | */ |
| 579 | - public function make($abstract) |
|
| 579 | + public function make( $abstract ) |
|
| 580 | 580 | { |
| 581 | - return $this->resolve($abstract); |
|
| 581 | + return $this->resolve( $abstract ); |
|
| 582 | 582 | } |
| 583 | 583 | |
| 584 | 584 | /** |
@@ -588,56 +588,56 @@ discard block |
||
| 588 | 588 | * @param array $parameters |
| 589 | 589 | * @return mixed |
| 590 | 590 | */ |
| 591 | - protected function resolve($abstract, $parameters = []) |
|
| 591 | + protected function resolve( $abstract, $parameters = [ ] ) |
|
| 592 | 592 | { |
| 593 | - $abstract = $this->getAlias($abstract); |
|
| 593 | + $abstract = $this->getAlias( $abstract ); |
|
| 594 | 594 | |
| 595 | - $needsContextualBuild = ! empty($parameters) || ! is_null( |
|
| 596 | - $this->getContextualConcrete($abstract) |
|
| 595 | + $needsContextualBuild = ! empty( $parameters ) || ! is_null( |
|
| 596 | + $this->getContextualConcrete( $abstract ) |
|
| 597 | 597 | ); |
| 598 | 598 | |
| 599 | 599 | // If an instance of the type is currently being managed as a singleton we'll |
| 600 | 600 | // just return an existing instance instead of instantiating new instances |
| 601 | 601 | // so the developer can keep using the same objects instance every time. |
| 602 | - if (isset($this->instances[$abstract]) && ! $needsContextualBuild) { |
|
| 603 | - return $this->instances[$abstract]; |
|
| 602 | + if ( isset( $this->instances[ $abstract ] ) && ! $needsContextualBuild ) { |
|
| 603 | + return $this->instances[ $abstract ]; |
|
| 604 | 604 | } |
| 605 | 605 | |
| 606 | - $this->with[] = $parameters; |
|
| 606 | + $this->with[ ] = $parameters; |
|
| 607 | 607 | |
| 608 | - $concrete = $this->getConcrete($abstract); |
|
| 608 | + $concrete = $this->getConcrete( $abstract ); |
|
| 609 | 609 | |
| 610 | 610 | // We're ready to instantiate an instance of the concrete type registered for |
| 611 | 611 | // the binding. This will instantiate the types, as well as resolve any of |
| 612 | 612 | // its "nested" dependencies recursively until all have gotten resolved. |
| 613 | - if ($this->isBuildable($concrete, $abstract)) { |
|
| 614 | - $object = $this->build($concrete); |
|
| 613 | + if ( $this->isBuildable( $concrete, $abstract ) ) { |
|
| 614 | + $object = $this->build( $concrete ); |
|
| 615 | 615 | } else { |
| 616 | - $object = $this->make($concrete); |
|
| 616 | + $object = $this->make( $concrete ); |
|
| 617 | 617 | } |
| 618 | 618 | |
| 619 | 619 | // If we defined any extenders for this type, we'll need to spin through them |
| 620 | 620 | // and apply them to the object being built. This allows for the extension |
| 621 | 621 | // of services, such as changing configuration or decorating the object. |
| 622 | - foreach ($this->getExtenders($abstract) as $extender) { |
|
| 623 | - $object = $extender($object, $this); |
|
| 622 | + foreach ( $this->getExtenders( $abstract ) as $extender ) { |
|
| 623 | + $object = $extender( $object, $this ); |
|
| 624 | 624 | } |
| 625 | 625 | |
| 626 | 626 | // If the requested type is registered as a singleton we'll want to cache off |
| 627 | 627 | // the instances in "memory" so we can return it later without creating an |
| 628 | 628 | // entirely new instance of an object on each subsequent request for it. |
| 629 | - if ($this->isShared($abstract) && ! $needsContextualBuild) { |
|
| 630 | - $this->instances[$abstract] = $object; |
|
| 629 | + if ( $this->isShared( $abstract ) && ! $needsContextualBuild ) { |
|
| 630 | + $this->instances[ $abstract ] = $object; |
|
| 631 | 631 | } |
| 632 | 632 | |
| 633 | - $this->fireResolvingCallbacks($abstract, $object); |
|
| 633 | + $this->fireResolvingCallbacks( $abstract, $object ); |
|
| 634 | 634 | |
| 635 | 635 | // Before returning, we will also set the resolved flag to "true" and pop off |
| 636 | 636 | // the parameter overrides for this build. After those two things are done |
| 637 | 637 | // we will be ready to return back the fully constructed class instance. |
| 638 | - $this->resolved[$abstract] = true; |
|
| 638 | + $this->resolved[ $abstract ] = true; |
|
| 639 | 639 | |
| 640 | - array_pop($this->with); |
|
| 640 | + array_pop( $this->with ); |
|
| 641 | 641 | |
| 642 | 642 | return $object; |
| 643 | 643 | } |
@@ -648,17 +648,17 @@ discard block |
||
| 648 | 648 | * @param string $abstract |
| 649 | 649 | * @return mixed $concrete |
| 650 | 650 | */ |
| 651 | - protected function getConcrete($abstract) |
|
| 651 | + protected function getConcrete( $abstract ) |
|
| 652 | 652 | { |
| 653 | - if (! is_null($concrete = $this->getContextualConcrete($abstract))) { |
|
| 653 | + if ( ! is_null( $concrete = $this->getContextualConcrete( $abstract ) ) ) { |
|
| 654 | 654 | return $concrete; |
| 655 | 655 | } |
| 656 | 656 | |
| 657 | 657 | // If we don't have a registered resolver or concrete for the type, we'll just |
| 658 | 658 | // assume each type is a concrete name and will attempt to resolve it as is |
| 659 | 659 | // since the container should be able to resolve concretes automatically. |
| 660 | - if (isset($this->bindings[$abstract])) { |
|
| 661 | - return $this->bindings[$abstract]['concrete']; |
|
| 660 | + if ( isset( $this->bindings[ $abstract ] ) ) { |
|
| 661 | + return $this->bindings[ $abstract ][ 'concrete' ]; |
|
| 662 | 662 | } |
| 663 | 663 | |
| 664 | 664 | return $abstract; |
@@ -670,21 +670,21 @@ discard block |
||
| 670 | 670 | * @param string $abstract |
| 671 | 671 | * @return string|null |
| 672 | 672 | */ |
| 673 | - protected function getContextualConcrete($abstract) |
|
| 673 | + protected function getContextualConcrete( $abstract ) |
|
| 674 | 674 | { |
| 675 | - if (! is_null($binding = $this->findInContextualBindings($abstract))) { |
|
| 675 | + if ( ! is_null( $binding = $this->findInContextualBindings( $abstract ) ) ) { |
|
| 676 | 676 | return $binding; |
| 677 | 677 | } |
| 678 | 678 | |
| 679 | 679 | // Next we need to see if a contextual binding might be bound under an alias of the |
| 680 | 680 | // given abstract type. So, we will need to check if any aliases exist with this |
| 681 | 681 | // type and then spin through them and check for contextual bindings on these. |
| 682 | - if (empty($this->abstractAliases[$abstract])) { |
|
| 682 | + if ( empty( $this->abstractAliases[ $abstract ] ) ) { |
|
| 683 | 683 | return; |
| 684 | 684 | } |
| 685 | 685 | |
| 686 | - foreach ($this->abstractAliases[$abstract] as $alias) { |
|
| 687 | - if (! is_null($binding = $this->findInContextualBindings($alias))) { |
|
| 686 | + foreach ( $this->abstractAliases[ $abstract ] as $alias ) { |
|
| 687 | + if ( ! is_null( $binding = $this->findInContextualBindings( $alias ) ) ) { |
|
| 688 | 688 | return $binding; |
| 689 | 689 | } |
| 690 | 690 | } |
@@ -696,10 +696,10 @@ discard block |
||
| 696 | 696 | * @param string $abstract |
| 697 | 697 | * @return string|null |
| 698 | 698 | */ |
| 699 | - protected function findInContextualBindings($abstract) |
|
| 699 | + protected function findInContextualBindings( $abstract ) |
|
| 700 | 700 | { |
| 701 | - if (isset($this->contextual[end($this->buildStack)][$abstract])) { |
|
| 702 | - return $this->contextual[end($this->buildStack)][$abstract]; |
|
| 701 | + if ( isset( $this->contextual[ end( $this->buildStack ) ][ $abstract ] ) ) { |
|
| 702 | + return $this->contextual[ end( $this->buildStack ) ][ $abstract ]; |
|
| 703 | 703 | } |
| 704 | 704 | } |
| 705 | 705 | |
@@ -710,7 +710,7 @@ discard block |
||
| 710 | 710 | * @param string $abstract |
| 711 | 711 | * @return bool |
| 712 | 712 | */ |
| 713 | - protected function isBuildable($concrete, $abstract) |
|
| 713 | + protected function isBuildable( $concrete, $abstract ) |
|
| 714 | 714 | { |
| 715 | 715 | return $concrete === $abstract || $concrete instanceof Closure; |
| 716 | 716 | } |
@@ -723,33 +723,33 @@ discard block |
||
| 723 | 723 | * |
| 724 | 724 | * @throws \GravityKit\GravityView\Foundation\ThirdParty\Illuminate\Contracts\Container\BindingResolutionException |
| 725 | 725 | */ |
| 726 | - public function build($concrete) |
|
| 726 | + public function build( $concrete ) |
|
| 727 | 727 | { |
| 728 | 728 | // If the concrete type is actually a Closure, we will just execute it and |
| 729 | 729 | // hand back the results of the functions, which allows functions to be |
| 730 | 730 | // used as resolvers for more fine-tuned resolution of these objects. |
| 731 | - if ($concrete instanceof Closure) { |
|
| 732 | - return $concrete($this, $this->getLastParameterOverride()); |
|
| 731 | + if ( $concrete instanceof Closure ) { |
|
| 732 | + return $concrete( $this, $this->getLastParameterOverride() ); |
|
| 733 | 733 | } |
| 734 | 734 | |
| 735 | - $reflector = new ReflectionClass($concrete); |
|
| 735 | + $reflector = new ReflectionClass( $concrete ); |
|
| 736 | 736 | |
| 737 | 737 | // If the type is not instantiable, the developer is attempting to resolve |
| 738 | 738 | // an abstract type such as an Interface of Abstract Class and there is |
| 739 | 739 | // no binding registered for the abstractions so we need to bail out. |
| 740 | - if (! $reflector->isInstantiable()) { |
|
| 741 | - return $this->notInstantiable($concrete); |
|
| 740 | + if ( ! $reflector->isInstantiable() ) { |
|
| 741 | + return $this->notInstantiable( $concrete ); |
|
| 742 | 742 | } |
| 743 | 743 | |
| 744 | - $this->buildStack[] = $concrete; |
|
| 744 | + $this->buildStack[ ] = $concrete; |
|
| 745 | 745 | |
| 746 | 746 | $constructor = $reflector->getConstructor(); |
| 747 | 747 | |
| 748 | 748 | // If there are no constructors, that means there are no dependencies then |
| 749 | 749 | // we can just resolve the instances of the objects right away, without |
| 750 | 750 | // resolving any other types or dependencies out of these containers. |
| 751 | - if (is_null($constructor)) { |
|
| 752 | - array_pop($this->buildStack); |
|
| 751 | + if ( is_null( $constructor ) ) { |
|
| 752 | + array_pop( $this->buildStack ); |
|
| 753 | 753 | |
| 754 | 754 | return new $concrete; |
| 755 | 755 | } |
@@ -763,9 +763,9 @@ discard block |
||
| 763 | 763 | $dependencies |
| 764 | 764 | ); |
| 765 | 765 | |
| 766 | - array_pop($this->buildStack); |
|
| 766 | + array_pop( $this->buildStack ); |
|
| 767 | 767 | |
| 768 | - return $reflector->newInstanceArgs($instances); |
|
| 768 | + return $reflector->newInstanceArgs( $instances ); |
|
| 769 | 769 | } |
| 770 | 770 | |
| 771 | 771 | /** |
@@ -774,16 +774,16 @@ discard block |
||
| 774 | 774 | * @param array $dependencies |
| 775 | 775 | * @return array |
| 776 | 776 | */ |
| 777 | - protected function resolveDependencies(array $dependencies) |
|
| 777 | + protected function resolveDependencies( array $dependencies ) |
|
| 778 | 778 | { |
| 779 | - $results = []; |
|
| 779 | + $results = [ ]; |
|
| 780 | 780 | |
| 781 | - foreach ($dependencies as $dependency) { |
|
| 781 | + foreach ( $dependencies as $dependency ) { |
|
| 782 | 782 | // If this dependency has a override for this particular build we will use |
| 783 | 783 | // that instead as the value. Otherwise, we will continue with this run |
| 784 | 784 | // of resolutions and let reflection attempt to determine the result. |
| 785 | - if ($this->hasParameterOverride($dependency)) { |
|
| 786 | - $results[] = $this->getParameterOverride($dependency); |
|
| 785 | + if ( $this->hasParameterOverride( $dependency ) ) { |
|
| 786 | + $results[ ] = $this->getParameterOverride( $dependency ); |
|
| 787 | 787 | |
| 788 | 788 | continue; |
| 789 | 789 | } |
@@ -791,9 +791,9 @@ discard block |
||
| 791 | 791 | // If the class is null, it means the dependency is a string or some other |
| 792 | 792 | // primitive type which we can not resolve since it is not a class and |
| 793 | 793 | // we will just bomb out with an error since we have no-where to go. |
| 794 | - $results[] = is_null($class = $dependency->getClass()) |
|
| 795 | - ? $this->resolvePrimitive($dependency) |
|
| 796 | - : $this->resolveClass($dependency); |
|
| 794 | + $results[ ] = is_null( $class = $dependency->getClass() ) |
|
| 795 | + ? $this->resolvePrimitive( $dependency ) |
|
| 796 | + : $this->resolveClass( $dependency ); |
|
| 797 | 797 | } |
| 798 | 798 | |
| 799 | 799 | return $results; |
@@ -805,7 +805,7 @@ discard block |
||
| 805 | 805 | * @param \ReflectionParameter $dependency |
| 806 | 806 | * @return bool |
| 807 | 807 | */ |
| 808 | - protected function hasParameterOverride($dependency) |
|
| 808 | + protected function hasParameterOverride( $dependency ) |
|
| 809 | 809 | { |
| 810 | 810 | return array_key_exists( |
| 811 | 811 | $dependency->name, $this->getLastParameterOverride() |
@@ -818,9 +818,9 @@ discard block |
||
| 818 | 818 | * @param \ReflectionParameter $dependency |
| 819 | 819 | * @return mixed |
| 820 | 820 | */ |
| 821 | - protected function getParameterOverride($dependency) |
|
| 821 | + protected function getParameterOverride( $dependency ) |
|
| 822 | 822 | { |
| 823 | - return $this->getLastParameterOverride()[$dependency->name]; |
|
| 823 | + return $this->getLastParameterOverride()[ $dependency->name ]; |
|
| 824 | 824 | } |
| 825 | 825 | |
| 826 | 826 | /** |
@@ -830,7 +830,7 @@ discard block |
||
| 830 | 830 | */ |
| 831 | 831 | protected function getLastParameterOverride() |
| 832 | 832 | { |
| 833 | - return count($this->with) ? end($this->with) : []; |
|
| 833 | + return count( $this->with ) ? end( $this->with ) : [ ]; |
|
| 834 | 834 | } |
| 835 | 835 | |
| 836 | 836 | /** |
@@ -841,17 +841,17 @@ discard block |
||
| 841 | 841 | * |
| 842 | 842 | * @throws \GravityKit\GravityView\Foundation\ThirdParty\Illuminate\Contracts\Container\BindingResolutionException |
| 843 | 843 | */ |
| 844 | - protected function resolvePrimitive(ReflectionParameter $parameter) |
|
| 844 | + protected function resolvePrimitive( ReflectionParameter $parameter ) |
|
| 845 | 845 | { |
| 846 | - if (! is_null($concrete = $this->getContextualConcrete('$'.$parameter->name))) { |
|
| 847 | - return $concrete instanceof Closure ? $concrete($this) : $concrete; |
|
| 846 | + if ( ! is_null( $concrete = $this->getContextualConcrete( '$' . $parameter->name ) ) ) { |
|
| 847 | + return $concrete instanceof Closure ? $concrete( $this ) : $concrete; |
|
| 848 | 848 | } |
| 849 | 849 | |
| 850 | - if ($parameter->isDefaultValueAvailable()) { |
|
| 850 | + if ( $parameter->isDefaultValueAvailable() ) { |
|
| 851 | 851 | return $parameter->getDefaultValue(); |
| 852 | 852 | } |
| 853 | 853 | |
| 854 | - $this->unresolvablePrimitive($parameter); |
|
| 854 | + $this->unresolvablePrimitive( $parameter ); |
|
| 855 | 855 | } |
| 856 | 856 | |
| 857 | 857 | /** |
@@ -862,17 +862,17 @@ discard block |
||
| 862 | 862 | * |
| 863 | 863 | * @throws \GravityKit\GravityView\Foundation\ThirdParty\Illuminate\Contracts\Container\BindingResolutionException |
| 864 | 864 | */ |
| 865 | - protected function resolveClass(ReflectionParameter $parameter) |
|
| 865 | + protected function resolveClass( ReflectionParameter $parameter ) |
|
| 866 | 866 | { |
| 867 | 867 | try { |
| 868 | - return $this->make($parameter->getClass()->name); |
|
| 868 | + return $this->make( $parameter->getClass()->name ); |
|
| 869 | 869 | } |
| 870 | 870 | |
| 871 | 871 | // If we can not resolve the class instance, we will check to see if the value |
| 872 | 872 | // is optional, and if it is we will return the optional parameter value as |
| 873 | 873 | // the value of the dependency, similarly to how we do this with scalars. |
| 874 | - catch (BindingResolutionException $e) { |
|
| 875 | - if ($parameter->isOptional()) { |
|
| 874 | + catch ( BindingResolutionException $e ) { |
|
| 875 | + if ( $parameter->isOptional() ) { |
|
| 876 | 876 | return $parameter->getDefaultValue(); |
| 877 | 877 | } |
| 878 | 878 | |
@@ -888,17 +888,17 @@ discard block |
||
| 888 | 888 | * |
| 889 | 889 | * @throws \GravityKit\GravityView\Foundation\ThirdParty\Illuminate\Contracts\Container\BindingResolutionException |
| 890 | 890 | */ |
| 891 | - protected function notInstantiable($concrete) |
|
| 891 | + protected function notInstantiable( $concrete ) |
|
| 892 | 892 | { |
| 893 | - if (! empty($this->buildStack)) { |
|
| 894 | - $previous = implode(', ', $this->buildStack); |
|
| 893 | + if ( ! empty( $this->buildStack ) ) { |
|
| 894 | + $previous = implode( ', ', $this->buildStack ); |
|
| 895 | 895 | |
| 896 | 896 | $message = "Target [$concrete] is not instantiable while building [$previous]."; |
| 897 | 897 | } else { |
| 898 | 898 | $message = "Target [$concrete] is not instantiable."; |
| 899 | 899 | } |
| 900 | 900 | |
| 901 | - throw new BindingResolutionException($message); |
|
| 901 | + throw new BindingResolutionException( $message ); |
|
| 902 | 902 | } |
| 903 | 903 | |
| 904 | 904 | /** |
@@ -909,11 +909,11 @@ discard block |
||
| 909 | 909 | * |
| 910 | 910 | * @throws \GravityKit\GravityView\Foundation\ThirdParty\Illuminate\Contracts\Container\BindingResolutionException |
| 911 | 911 | */ |
| 912 | - protected function unresolvablePrimitive(ReflectionParameter $parameter) |
|
| 912 | + protected function unresolvablePrimitive( ReflectionParameter $parameter ) |
|
| 913 | 913 | { |
| 914 | 914 | $message = "Unresolvable dependency resolving [$parameter] in class {$parameter->getDeclaringClass()->getName()}"; |
| 915 | 915 | |
| 916 | - throw new BindingResolutionException($message); |
|
| 916 | + throw new BindingResolutionException( $message ); |
|
| 917 | 917 | } |
| 918 | 918 | |
| 919 | 919 | /** |
@@ -923,16 +923,16 @@ discard block |
||
| 923 | 923 | * @param \Closure|null $callback |
| 924 | 924 | * @return void |
| 925 | 925 | */ |
| 926 | - public function resolving($abstract, Closure $callback = null) |
|
| 926 | + public function resolving( $abstract, Closure $callback = null ) |
|
| 927 | 927 | { |
| 928 | - if (is_string($abstract)) { |
|
| 929 | - $abstract = $this->getAlias($abstract); |
|
| 928 | + if ( is_string( $abstract ) ) { |
|
| 929 | + $abstract = $this->getAlias( $abstract ); |
|
| 930 | 930 | } |
| 931 | 931 | |
| 932 | - if (is_null($callback) && $abstract instanceof Closure) { |
|
| 933 | - $this->globalResolvingCallbacks[] = $abstract; |
|
| 932 | + if ( is_null( $callback ) && $abstract instanceof Closure ) { |
|
| 933 | + $this->globalResolvingCallbacks[ ] = $abstract; |
|
| 934 | 934 | } else { |
| 935 | - $this->resolvingCallbacks[$abstract][] = $callback; |
|
| 935 | + $this->resolvingCallbacks[ $abstract ][ ] = $callback; |
|
| 936 | 936 | } |
| 937 | 937 | } |
| 938 | 938 | |
@@ -943,16 +943,16 @@ discard block |
||
| 943 | 943 | * @param \Closure|null $callback |
| 944 | 944 | * @return void |
| 945 | 945 | */ |
| 946 | - public function afterResolving($abstract, Closure $callback = null) |
|
| 946 | + public function afterResolving( $abstract, Closure $callback = null ) |
|
| 947 | 947 | { |
| 948 | - if (is_string($abstract)) { |
|
| 949 | - $abstract = $this->getAlias($abstract); |
|
| 948 | + if ( is_string( $abstract ) ) { |
|
| 949 | + $abstract = $this->getAlias( $abstract ); |
|
| 950 | 950 | } |
| 951 | 951 | |
| 952 | - if ($abstract instanceof Closure && is_null($callback)) { |
|
| 953 | - $this->globalAfterResolvingCallbacks[] = $abstract; |
|
| 952 | + if ( $abstract instanceof Closure && is_null( $callback ) ) { |
|
| 953 | + $this->globalAfterResolvingCallbacks[ ] = $abstract; |
|
| 954 | 954 | } else { |
| 955 | - $this->afterResolvingCallbacks[$abstract][] = $callback; |
|
| 955 | + $this->afterResolvingCallbacks[ $abstract ][ ] = $callback; |
|
| 956 | 956 | } |
| 957 | 957 | } |
| 958 | 958 | |
@@ -963,15 +963,15 @@ discard block |
||
| 963 | 963 | * @param mixed $object |
| 964 | 964 | * @return void |
| 965 | 965 | */ |
| 966 | - protected function fireResolvingCallbacks($abstract, $object) |
|
| 966 | + protected function fireResolvingCallbacks( $abstract, $object ) |
|
| 967 | 967 | { |
| 968 | - $this->fireCallbackArray($object, $this->globalResolvingCallbacks); |
|
| 968 | + $this->fireCallbackArray( $object, $this->globalResolvingCallbacks ); |
|
| 969 | 969 | |
| 970 | 970 | $this->fireCallbackArray( |
| 971 | - $object, $this->getCallbacksForType($abstract, $object, $this->resolvingCallbacks) |
|
| 971 | + $object, $this->getCallbacksForType( $abstract, $object, $this->resolvingCallbacks ) |
|
| 972 | 972 | ); |
| 973 | 973 | |
| 974 | - $this->fireAfterResolvingCallbacks($abstract, $object); |
|
| 974 | + $this->fireAfterResolvingCallbacks( $abstract, $object ); |
|
| 975 | 975 | } |
| 976 | 976 | |
| 977 | 977 | /** |
@@ -981,12 +981,12 @@ discard block |
||
| 981 | 981 | * @param mixed $object |
| 982 | 982 | * @return void |
| 983 | 983 | */ |
| 984 | - protected function fireAfterResolvingCallbacks($abstract, $object) |
|
| 984 | + protected function fireAfterResolvingCallbacks( $abstract, $object ) |
|
| 985 | 985 | { |
| 986 | - $this->fireCallbackArray($object, $this->globalAfterResolvingCallbacks); |
|
| 986 | + $this->fireCallbackArray( $object, $this->globalAfterResolvingCallbacks ); |
|
| 987 | 987 | |
| 988 | 988 | $this->fireCallbackArray( |
| 989 | - $object, $this->getCallbacksForType($abstract, $object, $this->afterResolvingCallbacks) |
|
| 989 | + $object, $this->getCallbacksForType( $abstract, $object, $this->afterResolvingCallbacks ) |
|
| 990 | 990 | ); |
| 991 | 991 | } |
| 992 | 992 | |
@@ -999,13 +999,13 @@ discard block |
||
| 999 | 999 | * |
| 1000 | 1000 | * @return array |
| 1001 | 1001 | */ |
| 1002 | - protected function getCallbacksForType($abstract, $object, array $callbacksPerType) |
|
| 1002 | + protected function getCallbacksForType( $abstract, $object, array $callbacksPerType ) |
|
| 1003 | 1003 | { |
| 1004 | - $results = []; |
|
| 1004 | + $results = [ ]; |
|
| 1005 | 1005 | |
| 1006 | - foreach ($callbacksPerType as $type => $callbacks) { |
|
| 1007 | - if ($type === $abstract || $object instanceof $type) { |
|
| 1008 | - $results = array_merge($results, $callbacks); |
|
| 1006 | + foreach ( $callbacksPerType as $type => $callbacks ) { |
|
| 1007 | + if ( $type === $abstract || $object instanceof $type ) { |
|
| 1008 | + $results = array_merge( $results, $callbacks ); |
|
| 1009 | 1009 | } |
| 1010 | 1010 | } |
| 1011 | 1011 | |
@@ -1019,10 +1019,10 @@ discard block |
||
| 1019 | 1019 | * @param array $callbacks |
| 1020 | 1020 | * @return void |
| 1021 | 1021 | */ |
| 1022 | - protected function fireCallbackArray($object, array $callbacks) |
|
| 1022 | + protected function fireCallbackArray( $object, array $callbacks ) |
|
| 1023 | 1023 | { |
| 1024 | - foreach ($callbacks as $callback) { |
|
| 1025 | - $callback($object, $this); |
|
| 1024 | + foreach ( $callbacks as $callback ) { |
|
| 1025 | + $callback( $object, $this ); |
|
| 1026 | 1026 | } |
| 1027 | 1027 | } |
| 1028 | 1028 | |
@@ -1044,17 +1044,17 @@ discard block |
||
| 1044 | 1044 | * |
| 1045 | 1045 | * @throws \LogicException |
| 1046 | 1046 | */ |
| 1047 | - public function getAlias($abstract) |
|
| 1047 | + public function getAlias( $abstract ) |
|
| 1048 | 1048 | { |
| 1049 | - if (! isset($this->aliases[$abstract])) { |
|
| 1049 | + if ( ! isset( $this->aliases[ $abstract ] ) ) { |
|
| 1050 | 1050 | return $abstract; |
| 1051 | 1051 | } |
| 1052 | 1052 | |
| 1053 | - if ($this->aliases[$abstract] === $abstract) { |
|
| 1054 | - throw new LogicException("[{$abstract}] is aliased to itself."); |
|
| 1053 | + if ( $this->aliases[ $abstract ] === $abstract ) { |
|
| 1054 | + throw new LogicException( "[{$abstract}] is aliased to itself." ); |
|
| 1055 | 1055 | } |
| 1056 | 1056 | |
| 1057 | - return $this->getAlias($this->aliases[$abstract]); |
|
| 1057 | + return $this->getAlias( $this->aliases[ $abstract ] ); |
|
| 1058 | 1058 | } |
| 1059 | 1059 | |
| 1060 | 1060 | /** |
@@ -1063,15 +1063,15 @@ discard block |
||
| 1063 | 1063 | * @param string $abstract |
| 1064 | 1064 | * @return array |
| 1065 | 1065 | */ |
| 1066 | - protected function getExtenders($abstract) |
|
| 1066 | + protected function getExtenders( $abstract ) |
|
| 1067 | 1067 | { |
| 1068 | - $abstract = $this->getAlias($abstract); |
|
| 1068 | + $abstract = $this->getAlias( $abstract ); |
|
| 1069 | 1069 | |
| 1070 | - if (isset($this->extenders[$abstract])) { |
|
| 1071 | - return $this->extenders[$abstract]; |
|
| 1070 | + if ( isset( $this->extenders[ $abstract ] ) ) { |
|
| 1071 | + return $this->extenders[ $abstract ]; |
|
| 1072 | 1072 | } |
| 1073 | 1073 | |
| 1074 | - return []; |
|
| 1074 | + return [ ]; |
|
| 1075 | 1075 | } |
| 1076 | 1076 | |
| 1077 | 1077 | /** |
@@ -1080,9 +1080,9 @@ discard block |
||
| 1080 | 1080 | * @param string $abstract |
| 1081 | 1081 | * @return void |
| 1082 | 1082 | */ |
| 1083 | - public function forgetExtenders($abstract) |
|
| 1083 | + public function forgetExtenders( $abstract ) |
|
| 1084 | 1084 | { |
| 1085 | - unset($this->extenders[$this->getAlias($abstract)]); |
|
| 1085 | + unset( $this->extenders[ $this->getAlias( $abstract ) ] ); |
|
| 1086 | 1086 | } |
| 1087 | 1087 | |
| 1088 | 1088 | /** |
@@ -1091,9 +1091,9 @@ discard block |
||
| 1091 | 1091 | * @param string $abstract |
| 1092 | 1092 | * @return void |
| 1093 | 1093 | */ |
| 1094 | - protected function dropStaleInstances($abstract) |
|
| 1094 | + protected function dropStaleInstances( $abstract ) |
|
| 1095 | 1095 | { |
| 1096 | - unset($this->instances[$abstract], $this->aliases[$abstract]); |
|
| 1096 | + unset( $this->instances[ $abstract ], $this->aliases[ $abstract ] ); |
|
| 1097 | 1097 | } |
| 1098 | 1098 | |
| 1099 | 1099 | /** |
@@ -1102,9 +1102,9 @@ discard block |
||
| 1102 | 1102 | * @param string $abstract |
| 1103 | 1103 | * @return void |
| 1104 | 1104 | */ |
| 1105 | - public function forgetInstance($abstract) |
|
| 1105 | + public function forgetInstance( $abstract ) |
|
| 1106 | 1106 | { |
| 1107 | - unset($this->instances[$abstract]); |
|
| 1107 | + unset( $this->instances[ $abstract ] ); |
|
| 1108 | 1108 | } |
| 1109 | 1109 | |
| 1110 | 1110 | /** |
@@ -1114,7 +1114,7 @@ discard block |
||
| 1114 | 1114 | */ |
| 1115 | 1115 | public function forgetInstances() |
| 1116 | 1116 | { |
| 1117 | - $this->instances = []; |
|
| 1117 | + $this->instances = [ ]; |
|
| 1118 | 1118 | } |
| 1119 | 1119 | |
| 1120 | 1120 | /** |
@@ -1124,11 +1124,11 @@ discard block |
||
| 1124 | 1124 | */ |
| 1125 | 1125 | public function flush() |
| 1126 | 1126 | { |
| 1127 | - $this->aliases = []; |
|
| 1128 | - $this->resolved = []; |
|
| 1129 | - $this->bindings = []; |
|
| 1130 | - $this->instances = []; |
|
| 1131 | - $this->abstractAliases = []; |
|
| 1127 | + $this->aliases = [ ]; |
|
| 1128 | + $this->resolved = [ ]; |
|
| 1129 | + $this->bindings = [ ]; |
|
| 1130 | + $this->instances = [ ]; |
|
| 1131 | + $this->abstractAliases = [ ]; |
|
| 1132 | 1132 | } |
| 1133 | 1133 | |
| 1134 | 1134 | /** |
@@ -1138,7 +1138,7 @@ discard block |
||
| 1138 | 1138 | */ |
| 1139 | 1139 | public static function getInstance() |
| 1140 | 1140 | { |
| 1141 | - if (is_null(static::$instance)) { |
|
| 1141 | + if ( is_null( static::$instance ) ) { |
|
| 1142 | 1142 | static::$instance = new static; |
| 1143 | 1143 | } |
| 1144 | 1144 | |
@@ -1151,7 +1151,7 @@ discard block |
||
| 1151 | 1151 | * @param \GravityKit\GravityView\Foundation\ThirdParty\Illuminate\Contracts\Container\Container|null $container |
| 1152 | 1152 | * @return static |
| 1153 | 1153 | */ |
| 1154 | - public static function setInstance(ContainerContract $container = null) |
|
| 1154 | + public static function setInstance( ContainerContract $container = null ) |
|
| 1155 | 1155 | { |
| 1156 | 1156 | return static::$instance = $container; |
| 1157 | 1157 | } |
@@ -1162,9 +1162,9 @@ discard block |
||
| 1162 | 1162 | * @param string $key |
| 1163 | 1163 | * @return bool |
| 1164 | 1164 | */ |
| 1165 | - public function offsetExists($key) |
|
| 1165 | + public function offsetExists( $key ) |
|
| 1166 | 1166 | { |
| 1167 | - return $this->bound($key); |
|
| 1167 | + return $this->bound( $key ); |
|
| 1168 | 1168 | } |
| 1169 | 1169 | |
| 1170 | 1170 | /** |
@@ -1173,9 +1173,9 @@ discard block |
||
| 1173 | 1173 | * @param string $key |
| 1174 | 1174 | * @return mixed |
| 1175 | 1175 | */ |
| 1176 | - public function offsetGet($key) |
|
| 1176 | + public function offsetGet( $key ) |
|
| 1177 | 1177 | { |
| 1178 | - return $this->make($key); |
|
| 1178 | + return $this->make( $key ); |
|
| 1179 | 1179 | } |
| 1180 | 1180 | |
| 1181 | 1181 | /** |
@@ -1185,9 +1185,9 @@ discard block |
||
| 1185 | 1185 | * @param mixed $value |
| 1186 | 1186 | * @return void |
| 1187 | 1187 | */ |
| 1188 | - public function offsetSet($key, $value) |
|
| 1188 | + public function offsetSet( $key, $value ) |
|
| 1189 | 1189 | { |
| 1190 | - $this->bind($key, $value instanceof Closure ? $value : function () use ($value) { |
|
| 1190 | + $this->bind( $key, $value instanceof Closure ? $value : function() use ( $value ) { |
|
| 1191 | 1191 | return $value; |
| 1192 | 1192 | }); |
| 1193 | 1193 | } |
@@ -1198,9 +1198,9 @@ discard block |
||
| 1198 | 1198 | * @param string $key |
| 1199 | 1199 | * @return void |
| 1200 | 1200 | */ |
| 1201 | - public function offsetUnset($key) |
|
| 1201 | + public function offsetUnset( $key ) |
|
| 1202 | 1202 | { |
| 1203 | - unset($this->bindings[$key], $this->instances[$key], $this->resolved[$key]); |
|
| 1203 | + unset( $this->bindings[ $key ], $this->instances[ $key ], $this->resolved[ $key ] ); |
|
| 1204 | 1204 | } |
| 1205 | 1205 | |
| 1206 | 1206 | /** |
@@ -1209,9 +1209,9 @@ discard block |
||
| 1209 | 1209 | * @param string $key |
| 1210 | 1210 | * @return mixed |
| 1211 | 1211 | */ |
| 1212 | - public function __get($key) |
|
| 1212 | + public function __get( $key ) |
|
| 1213 | 1213 | { |
| 1214 | - return $this[$key]; |
|
| 1214 | + return $this[ $key ]; |
|
| 1215 | 1215 | } |
| 1216 | 1216 | |
| 1217 | 1217 | /** |
@@ -1221,8 +1221,8 @@ discard block |
||
| 1221 | 1221 | * @param mixed $value |
| 1222 | 1222 | * @return void |
| 1223 | 1223 | */ |
| 1224 | - public function __set($key, $value) |
|
| 1224 | + public function __set( $key, $value ) |
|
| 1225 | 1225 | { |
| 1226 | - $this[$key] = $value; |
|
| 1226 | + $this[ $key ] = $value; |
|
| 1227 | 1227 | } |
| 1228 | 1228 | } |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | * @param string $concrete |
| 41 | 41 | * @return void |
| 42 | 42 | */ |
| 43 | - public function __construct(Container $container, $concrete) |
|
| 43 | + public function __construct( Container $container, $concrete ) |
|
| 44 | 44 | { |
| 45 | 45 | $this->concrete = $concrete; |
| 46 | 46 | $this->container = $container; |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | * @param string $abstract |
| 53 | 53 | * @return $this |
| 54 | 54 | */ |
| 55 | - public function needs($abstract) |
|
| 55 | + public function needs( $abstract ) |
|
| 56 | 56 | { |
| 57 | 57 | $this->needs = $abstract; |
| 58 | 58 | |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | * @param \Closure|string $implementation |
| 66 | 66 | * @return void |
| 67 | 67 | */ |
| 68 | - public function give($implementation) |
|
| 68 | + public function give( $implementation ) |
|
| 69 | 69 | { |
| 70 | 70 | $this->container->addContextualBinding( |
| 71 | 71 | $this->concrete, $this->needs, $implementation |
@@ -24,15 +24,15 @@ discard block |
||
| 24 | 24 | * @param string|null $defaultMethod |
| 25 | 25 | * @return mixed |
| 26 | 26 | */ |
| 27 | - public static function call($container, $callback, array $parameters = [], $defaultMethod = null) |
|
| 27 | + public static function call( $container, $callback, array $parameters = [ ], $defaultMethod = null ) |
|
| 28 | 28 | { |
| 29 | - if (static::isCallableWithAtSign($callback) || $defaultMethod) { |
|
| 30 | - return static::callClass($container, $callback, $parameters, $defaultMethod); |
|
| 29 | + if ( static::isCallableWithAtSign( $callback ) || $defaultMethod ) { |
|
| 30 | + return static::callClass( $container, $callback, $parameters, $defaultMethod ); |
|
| 31 | 31 | } |
| 32 | 32 | |
| 33 | - return static::callBoundMethod($container, $callback, function () use ($container, $callback, $parameters) { |
|
| 33 | + return static::callBoundMethod( $container, $callback, function() use ( $container, $callback, $parameters ) { |
|
| 34 | 34 | return call_user_func_array( |
| 35 | - $callback, static::getMethodDependencies($container, $callback, $parameters) |
|
| 35 | + $callback, static::getMethodDependencies( $container, $callback, $parameters ) |
|
| 36 | 36 | ); |
| 37 | 37 | }); |
| 38 | 38 | } |
@@ -48,22 +48,22 @@ discard block |
||
| 48 | 48 | * |
| 49 | 49 | * @throws \InvalidArgumentException |
| 50 | 50 | */ |
| 51 | - protected static function callClass($container, $target, array $parameters = [], $defaultMethod = null) |
|
| 51 | + protected static function callClass( $container, $target, array $parameters = [ ], $defaultMethod = null ) |
|
| 52 | 52 | { |
| 53 | - $segments = explode('@', $target); |
|
| 53 | + $segments = explode( '@', $target ); |
|
| 54 | 54 | |
| 55 | 55 | // We will assume an @ sign is used to delimit the class name from the method |
| 56 | 56 | // name. We will split on this @ sign and then build a callable array that |
| 57 | 57 | // we can pass right back into the "call" method for dependency binding. |
| 58 | - $method = count($segments) == 2 |
|
| 59 | - ? $segments[1] : $defaultMethod; |
|
| 58 | + $method = count( $segments ) == 2 |
|
| 59 | + ? $segments[ 1 ] : $defaultMethod; |
|
| 60 | 60 | |
| 61 | - if (is_null($method)) { |
|
| 62 | - throw new InvalidArgumentException('Method not provided.'); |
|
| 61 | + if ( is_null( $method ) ) { |
|
| 62 | + throw new InvalidArgumentException( 'Method not provided.' ); |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | return static::call( |
| 66 | - $container, [$container->make($segments[0]), $method], $parameters |
|
| 66 | + $container, [ $container->make( $segments[ 0 ] ), $method ], $parameters |
|
| 67 | 67 | ); |
| 68 | 68 | } |
| 69 | 69 | |
@@ -75,19 +75,19 @@ discard block |
||
| 75 | 75 | * @param mixed $default |
| 76 | 76 | * @return mixed |
| 77 | 77 | */ |
| 78 | - protected static function callBoundMethod($container, $callback, $default) |
|
| 78 | + protected static function callBoundMethod( $container, $callback, $default ) |
|
| 79 | 79 | { |
| 80 | - if (! is_array($callback)) { |
|
| 80 | + if ( ! is_array( $callback ) ) { |
|
| 81 | 81 | return $default instanceof Closure ? $default() : $default; |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | // Here we need to turn the array callable into a Class@method string we can use to |
| 85 | 85 | // examine the container and see if there are any method bindings for this given |
| 86 | 86 | // method. If there are, we can call this method binding callback immediately. |
| 87 | - $method = static::normalizeMethod($callback); |
|
| 87 | + $method = static::normalizeMethod( $callback ); |
|
| 88 | 88 | |
| 89 | - if ($container->hasMethodBinding($method)) { |
|
| 90 | - return $container->callMethodBinding($method, $callback[0]); |
|
| 89 | + if ( $container->hasMethodBinding( $method ) ) { |
|
| 90 | + return $container->callMethodBinding( $method, $callback[ 0 ] ); |
|
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | return $default instanceof Closure ? $default() : $default; |
@@ -99,11 +99,11 @@ discard block |
||
| 99 | 99 | * @param callable $callback |
| 100 | 100 | * @return string |
| 101 | 101 | */ |
| 102 | - protected static function normalizeMethod($callback) |
|
| 102 | + protected static function normalizeMethod( $callback ) |
|
| 103 | 103 | { |
| 104 | - $class = is_string($callback[0]) ? $callback[0] : get_class($callback[0]); |
|
| 104 | + $class = is_string( $callback[ 0 ] ) ? $callback[ 0 ] : get_class( $callback[ 0 ] ); |
|
| 105 | 105 | |
| 106 | - return "{$class}@{$callback[1]}"; |
|
| 106 | + return "{$class}@{$callback[ 1 ]}"; |
|
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | /** |
@@ -114,15 +114,15 @@ discard block |
||
| 114 | 114 | * @param array $parameters |
| 115 | 115 | * @return array |
| 116 | 116 | */ |
| 117 | - protected static function getMethodDependencies($container, $callback, array $parameters = []) |
|
| 117 | + protected static function getMethodDependencies( $container, $callback, array $parameters = [ ] ) |
|
| 118 | 118 | { |
| 119 | - $dependencies = []; |
|
| 119 | + $dependencies = [ ]; |
|
| 120 | 120 | |
| 121 | - foreach (static::getCallReflector($callback)->getParameters() as $parameter) { |
|
| 122 | - static::addDependencyForCallParameter($container, $parameter, $parameters, $dependencies); |
|
| 121 | + foreach ( static::getCallReflector( $callback )->getParameters() as $parameter ) { |
|
| 122 | + static::addDependencyForCallParameter( $container, $parameter, $parameters, $dependencies ); |
|
| 123 | 123 | } |
| 124 | 124 | |
| 125 | - return array_merge($dependencies, $parameters); |
|
| 125 | + return array_merge( $dependencies, $parameters ); |
|
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | /** |
@@ -131,15 +131,15 @@ discard block |
||
| 131 | 131 | * @param callable|string $callback |
| 132 | 132 | * @return \ReflectionFunctionAbstract |
| 133 | 133 | */ |
| 134 | - protected static function getCallReflector($callback) |
|
| 134 | + protected static function getCallReflector( $callback ) |
|
| 135 | 135 | { |
| 136 | - if (is_string($callback) && strpos($callback, '::') !== false) { |
|
| 137 | - $callback = explode('::', $callback); |
|
| 136 | + if ( is_string( $callback ) && strpos( $callback, '::' ) !== false ) { |
|
| 137 | + $callback = explode( '::', $callback ); |
|
| 138 | 138 | } |
| 139 | 139 | |
| 140 | - return is_array($callback) |
|
| 141 | - ? new ReflectionMethod($callback[0], $callback[1]) |
|
| 142 | - : new ReflectionFunction($callback); |
|
| 140 | + return is_array( $callback ) |
|
| 141 | + ? new ReflectionMethod( $callback[ 0 ], $callback[ 1 ] ) |
|
| 142 | + : new ReflectionFunction( $callback ); |
|
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | /** |
@@ -151,17 +151,17 @@ discard block |
||
| 151 | 151 | * @param array $dependencies |
| 152 | 152 | * @return mixed |
| 153 | 153 | */ |
| 154 | - protected static function addDependencyForCallParameter($container, $parameter, |
|
| 155 | - array &$parameters, &$dependencies) |
|
| 154 | + protected static function addDependencyForCallParameter( $container, $parameter, |
|
| 155 | + array &$parameters, &$dependencies ) |
|
| 156 | 156 | { |
| 157 | - if (array_key_exists($parameter->name, $parameters)) { |
|
| 158 | - $dependencies[] = $parameters[$parameter->name]; |
|
| 159 | - |
|
| 160 | - unset($parameters[$parameter->name]); |
|
| 161 | - } elseif ($parameter->getClass()) { |
|
| 162 | - $dependencies[] = $container->make($parameter->getClass()->name); |
|
| 163 | - } elseif ($parameter->isDefaultValueAvailable()) { |
|
| 164 | - $dependencies[] = $parameter->getDefaultValue(); |
|
| 157 | + if ( array_key_exists( $parameter->name, $parameters ) ) { |
|
| 158 | + $dependencies[ ] = $parameters[ $parameter->name ]; |
|
| 159 | + |
|
| 160 | + unset( $parameters[ $parameter->name ] ); |
|
| 161 | + } elseif ( $parameter->getClass() ) { |
|
| 162 | + $dependencies[ ] = $container->make( $parameter->getClass()->name ); |
|
| 163 | + } elseif ( $parameter->isDefaultValueAvailable() ) { |
|
| 164 | + $dependencies[ ] = $parameter->getDefaultValue(); |
|
| 165 | 165 | } |
| 166 | 166 | } |
| 167 | 167 | |
@@ -171,8 +171,8 @@ discard block |
||
| 171 | 171 | * @param mixed $callback |
| 172 | 172 | * @return bool |
| 173 | 173 | */ |
| 174 | - protected static function isCallableWithAtSign($callback) |
|
| 174 | + protected static function isCallableWithAtSign( $callback ) |
|
| 175 | 175 | { |
| 176 | - return is_string($callback) && strpos($callback, '@') !== false; |
|
| 176 | + return is_string( $callback ) && strpos( $callback, '@' ) !== false; |
|
| 177 | 177 | } |
| 178 | 178 | } |