@@ -39,7 +39,7 @@ |
||
| 39 | 39 | protected function buildNamespace(array $classes) |
| 40 | 40 | { |
| 41 | 41 | // Transform all class names. |
| 42 | - array_walk($classes, function (&$class, $key) { |
|
| 42 | + array_walk($classes, function(&$class, $key) { |
|
| 43 | 43 | |
| 44 | 44 | // Determine wheter class starts with backslash. |
| 45 | 45 | $appends = starts_with($class, '\\'); |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | public function compile(string $url): string |
| 35 | 35 | { |
| 36 | 36 | // Parse each fragment on url. |
| 37 | - $fragments = array_map(function ($fragment) { |
|
| 37 | + $fragments = array_map(function($fragment) { |
|
| 38 | 38 | if ($this->getParser()->isParameterDynamic($fragment)) { |
| 39 | 39 | |
| 40 | 40 | // We assume the parameter fragment is dynamic for |
@@ -58,14 +58,14 @@ discard block |
||
| 58 | 58 | { |
| 59 | 59 | $fragments = $this->parseUrlFragments($url); |
| 60 | 60 | |
| 61 | - $dynamicParameters = array_filter($fragments, function ($parameter) { |
|
| 61 | + $dynamicParameters = array_filter($fragments, function($parameter) { |
|
| 62 | 62 | |
| 63 | 63 | // Determine wheter the parameter is dynamic on parser |
| 64 | 64 | // and should be kept. |
| 65 | 65 | return $this->getParser()->isParameterDynamic($parameter); |
| 66 | 66 | }); |
| 67 | 67 | |
| 68 | - return array_map(function ($parameter) { |
|
| 68 | + return array_map(function($parameter) { |
|
| 69 | 69 | |
| 70 | 70 | // Return the matches for the dynamic parameter. |
| 71 | 71 | return $this->getParser()->getMatches($parameter); |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | */ |
| 81 | 81 | public function hasDynamics(string $url): bool |
| 82 | 82 | { |
| 83 | - return ! empty(array_values($this->parseDynamics($url))); |
|
| 83 | + return !empty(array_values($this->parseDynamics($url))); |
|
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | /** |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | * |
| 16 | 16 | * @var array |
| 17 | 17 | */ |
| 18 | - protected $configuration = []; |
|
| 18 | + protected $configuration = [ ]; |
|
| 19 | 19 | |
| 20 | 20 | /** |
| 21 | 21 | * The base namespace for the models. |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | */ |
| 44 | 44 | public function has($key) |
| 45 | 45 | { |
| 46 | - return isset($this->configuration[$key]); |
|
| 46 | + return isset($this->configuration[ $key ]); |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | /** |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | */ |
| 56 | 56 | public function get($key, $default = null) |
| 57 | 57 | { |
| 58 | - return $this->has($key) ? $this->configuration[$key] : $default; |
|
| 58 | + return $this->has($key) ? $this->configuration[ $key ] : $default; |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | /** |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | $key = $this->getModelFromKey($key); |
| 90 | 90 | |
| 91 | 91 | // Set the configuration. |
| 92 | - $this->configuration[$key] = $value; |
|
| 92 | + $this->configuration[ $key ] = $value; |
|
| 93 | 93 | } |
| 94 | 94 | } |
| 95 | 95 | |
@@ -144,12 +144,12 @@ discard block |
||
| 144 | 144 | { |
| 145 | 145 | $model = $key; |
| 146 | 146 | |
| 147 | - if (str_contains($key, '.') || ! str_contains($key, '\\')) { |
|
| 147 | + if (str_contains($key, '.') || !str_contains($key, '\\')) { |
|
| 148 | 148 | |
| 149 | 149 | // Build the class namespace using the base model namespace |
| 150 | 150 | // and the parts of the key splitted by dots. |
| 151 | 151 | $model = $this->buildNamespace(array_merge( |
| 152 | - [$this->modelsNamespace], |
|
| 152 | + [ $this->modelsNamespace ], |
|
| 153 | 153 | array_map('ucfirst', explode('.', $key)) |
| 154 | 154 | )); |
| 155 | 155 | } |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | */ |
| 105 | 105 | public function addFormatters($formatters) |
| 106 | 106 | { |
| 107 | - array_walk($formatters, function ($formatter, $name) { |
|
| 107 | + array_walk($formatters, function($formatter, $name) { |
|
| 108 | 108 | $this->addFormatter($formatter, is_int($name) ? null : $name); |
| 109 | 109 | }); |
| 110 | 110 | |
@@ -214,7 +214,7 @@ discard block |
||
| 214 | 214 | * @param array $params |
| 215 | 215 | * @return mixed |
| 216 | 216 | */ |
| 217 | - protected function callFormatter($formatter, array $params = []) |
|
| 217 | + protected function callFormatter($formatter, array $params = [ ]) |
|
| 218 | 218 | { |
| 219 | 219 | return $this->getContainer()->call($formatter, $params); |
| 220 | 220 | } |
@@ -239,7 +239,7 @@ discard block |
||
| 239 | 239 | $formatter = $this->getContainer()->make($formatter); |
| 240 | 240 | } |
| 241 | 241 | |
| 242 | - return [$formatter, 'format']; |
|
| 242 | + return [ $formatter, 'format' ]; |
|
| 243 | 243 | } |
| 244 | 244 | |
| 245 | 245 | /** |
@@ -177,14 +177,14 @@ |
||
| 177 | 177 | }); |
| 178 | 178 | } |
| 179 | 179 | |
| 180 | - /** |
|
| 181 | - * Copy the file from the source model to the destiny model. |
|
| 182 | - * |
|
| 183 | - * @param \Illuminate\Database\Eloquent\Model $from |
|
| 184 | - * @param \Illuminate\Database\Eloquent\Model $to |
|
| 185 | - * @param bool|null $preserveName |
|
| 186 | - * @return \Illuminate\Database\Eloquent\Model |
|
| 187 | - */ |
|
| 180 | + /** |
|
| 181 | + * Copy the file from the source model to the destiny model. |
|
| 182 | + * |
|
| 183 | + * @param \Illuminate\Database\Eloquent\Model $from |
|
| 184 | + * @param \Illuminate\Database\Eloquent\Model $to |
|
| 185 | + * @param bool|null $preserveName |
|
| 186 | + * @return \Illuminate\Database\Eloquent\Model |
|
| 187 | + */ |
|
| 188 | 188 | public function copy(Model $from, Model $to, bool $preserveName = null) |
| 189 | 189 | { |
| 190 | 190 | $this->supportLincable([$from, $to]); |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | { |
| 51 | 51 | $this->app = $app; |
| 52 | 52 | $this->urlGenerator = $urlGenerator; |
| 53 | - $this->disk = $app['filesystem']->disk($this->config('disk')); |
|
| 53 | + $this->disk = $app[ 'filesystem' ]->disk($this->config('disk')); |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | /** |
@@ -138,28 +138,28 @@ discard block |
||
| 138 | 138 | public function upload( |
| 139 | 139 | File $media, |
| 140 | 140 | Model $model, |
| 141 | - $options = [] |
|
| 141 | + $options = [ ] |
|
| 142 | 142 | ) { |
| 143 | 143 | $this->supportLincable($model); |
| 144 | 144 | |
| 145 | 145 | // Create the model link. |
| 146 | 146 | $link = $this->newLink($model); |
| 147 | 147 | |
| 148 | - return rescue(function () use ($link, $media, $model, $options) { |
|
| 148 | + return rescue(function() use ($link, $media, $model, $options) { |
|
| 149 | 149 | // Define the arguments list and method to the media upload. |
| 150 | - list($arguments, $putMethod) = [[$link, $media], 'putFile']; |
|
| 150 | + list($arguments, $putMethod) = [ [ $link, $media ], 'putFile' ]; |
|
| 151 | 151 | |
| 152 | 152 | // Determine wheter the model already has a file linked to reuse |
| 153 | 153 | // the same url. Then the media filename is inserted into the arguments |
| 154 | 154 | // and we change the upload method to accept a filename. |
| 155 | 155 | if ($model->getRawUrl()) { |
| 156 | - $arguments[] = $model->getFileName(); |
|
| 156 | + $arguments[ ] = $model->getFileName(); |
|
| 157 | 157 | $putMethod = 'putFileAs'; |
| 158 | 158 | } |
| 159 | 159 | |
| 160 | 160 | // Here we allow custom upload options that is independent from |
| 161 | 161 | // the method used. |
| 162 | - $arguments[] = $options; |
|
| 162 | + $arguments[ ] = $options; |
|
| 163 | 163 | |
| 164 | 164 | $url = $this->disk->$putMethod(...$arguments); |
| 165 | 165 | |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | event(new UploadSuccess($model, $media)); |
| 170 | 170 | |
| 171 | 171 | return $model; |
| 172 | - }, function () use ($model, $media) { |
|
| 172 | + }, function() use ($model, $media) { |
|
| 173 | 173 | // Send the event that the upload has failed. |
| 174 | 174 | event(new UploadFailure($model, $media)); |
| 175 | 175 | |
@@ -187,13 +187,12 @@ discard block |
||
| 187 | 187 | */ |
| 188 | 188 | public function copy(Model $from, Model $to, bool $preserveName = null) |
| 189 | 189 | { |
| 190 | - $this->supportLincable([$from, $to]); |
|
| 190 | + $this->supportLincable([ $from, $to ]); |
|
| 191 | 191 | |
| 192 | 192 | $path = $this->newLink( |
| 193 | 193 | $to, |
| 194 | 194 | $preserveName ? |
| 195 | - $from->getFileName() : |
|
| 196 | - str_random(40).'.'.$from->getExtension() |
|
| 195 | + $from->getFileName() : str_random(40).'.'.$from->getExtension() |
|
| 197 | 196 | ); |
| 198 | 197 | |
| 199 | 198 | $this->disk->copy($from->getRawUrl(), $path); |
@@ -216,7 +215,7 @@ discard block |
||
| 216 | 215 | $modelUrl = $path->getRawUrl(); |
| 217 | 216 | |
| 218 | 217 | // Do not keep the model on. |
| 219 | - if (! $dryRun) { |
|
| 218 | + if (!$dryRun) { |
|
| 220 | 219 | $path->delete(); |
| 221 | 220 | } |
| 222 | 221 | |
@@ -293,7 +292,7 @@ discard block |
||
| 293 | 292 | |
| 294 | 293 | $modelClass = get_class($model); |
| 295 | 294 | |
| 296 | - if (! $this->hasLincableTrait($modelClass)) { |
|
| 295 | + if (!$this->hasLincableTrait($modelClass)) { |
|
| 297 | 296 | throw new Exception("The model [$modelClass] does not support Lincable."); |
| 298 | 297 | } |
| 299 | 298 | } |
@@ -343,10 +342,10 @@ discard block |
||
| 343 | 342 | } |
| 344 | 343 | |
| 345 | 344 | if ( |
| 346 | - $arguments[0] instanceof Model && |
|
| 347 | - $this->hasLincableTrait(get_class($arguments[0])) |
|
| 345 | + $arguments[ 0 ] instanceof Model && |
|
| 346 | + $this->hasLincableTrait(get_class($arguments[ 0 ])) |
|
| 348 | 347 | ) { |
| 349 | - $arguments[0] = $arguments[0]->getRawUrl(); |
|
| 348 | + $arguments[ 0 ] = $arguments[ 0 ]->getRawUrl(); |
|
| 350 | 349 | } |
| 351 | 350 | |
| 352 | 351 | return $this->forwardCallTo($this->disk, $name, $arguments); |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | |
| 34 | 34 | $this->mergeConfigFrom($configPath, 'lincable'); |
| 35 | 35 | |
| 36 | - $this->app['events']->subscribe($this->app['config']['lincable.upload_subscriber']); |
|
| 36 | + $this->app[ 'events' ]->subscribe($this->app[ 'config' ][ 'lincable.upload_subscriber' ]); |
|
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | /** |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | */ |
| 56 | 56 | public function provides() |
| 57 | 57 | { |
| 58 | - return [MediaManager::class]; |
|
| 58 | + return [ MediaManager::class ]; |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | /** |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | */ |
| 66 | 66 | public function registerMediaManager() |
| 67 | 67 | { |
| 68 | - $this->app->singleton(MediaManager::class, function ($app) { |
|
| 68 | + $this->app->singleton(MediaManager::class, function($app) { |
|
| 69 | 69 | return new MediaManager($app, $app->make(UrlGenerator::class)); |
| 70 | 70 | }); |
| 71 | 71 | } |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | */ |
| 115 | 115 | public function registerUrlGenerator() |
| 116 | 116 | { |
| 117 | - $this->app->singleton(UrlGenerator::class, function ($app) { |
|
| 117 | + $this->app->singleton(UrlGenerator::class, function($app) { |
|
| 118 | 118 | return new UrlGenerator( |
| 119 | 119 | $app->make(Compiler::class), |
| 120 | 120 | $this->createParsers(), |
@@ -132,12 +132,12 @@ discard block |
||
| 132 | 132 | { |
| 133 | 133 | // Create the default parsers from config. |
| 134 | 134 | $registeredParsers = collect(array_merge( |
| 135 | - config('lincable.default_parsers', []), |
|
| 136 | - config('lincable.parsers', []) |
|
| 135 | + config('lincable.default_parsers', [ ]), |
|
| 136 | + config('lincable.parsers', [ ]) |
|
| 137 | 137 | )); |
| 138 | 138 | |
| 139 | - return $registeredParsers->map(function ($formatters, $parser) { |
|
| 140 | - return tap($this->app->make($parser), function ($parser) use ($formatters) { |
|
| 139 | + return $registeredParsers->map(function($formatters, $parser) { |
|
| 140 | + return tap($this->app->make($parser), function($parser) use ($formatters) { |
|
| 141 | 141 | $parser->addFormatters($formatters); |
| 142 | 142 | }); |
| 143 | 143 | }); |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | */ |
| 118 | 118 | protected function parseValidationRules() |
| 119 | 119 | { |
| 120 | - return [$this->getParameter() => $this->container->call([$this, 'rules'])]; |
|
| 120 | + return [ $this->getParameter() => $this->container->call([ $this, 'rules' ]) ]; |
|
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | /** |
@@ -140,12 +140,12 @@ discard block |
||
| 140 | 140 | */ |
| 141 | 141 | protected function executeFileEvents(File $file) |
| 142 | 142 | { |
| 143 | - $callable = [$this, 'beforeSend']; |
|
| 143 | + $callable = [ $this, 'beforeSend' ]; |
|
| 144 | 144 | |
| 145 | - if (method_exists($callable[0], $callable[1])) { |
|
| 145 | + if (method_exists($callable[ 0 ], $callable[ 1 ])) { |
|
| 146 | 146 | |
| 147 | 147 | // Handle the result from event call. |
| 148 | - if ($result = $this->container->call($callable, [$file])) { |
|
| 148 | + if ($result = $this->container->call($callable, [ $file ])) { |
|
| 149 | 149 | return $result; |
| 150 | 150 | } |
| 151 | 151 | } |
@@ -32,7 +32,7 @@ |
||
| 32 | 32 | */ |
| 33 | 33 | protected static function bootCloneLinks() |
| 34 | 34 | { |
| 35 | - static::created(function ($model) { |
|
| 35 | + static::created(function($model) { |
|
| 36 | 36 | static::copyCloneMedia($model); |
| 37 | 37 | }); |
| 38 | 38 | } |
@@ -28,8 +28,8 @@ discard block |
||
| 28 | 28 | */ |
| 29 | 29 | protected static function bootLincable() |
| 30 | 30 | { |
| 31 | - static::deleted(function ($model) { |
|
| 32 | - if (! $model->shouldKeepMediaWhenDeleted()) { |
|
| 31 | + static::deleted(function($model) { |
|
| 32 | + if (!$model->shouldKeepMediaWhenDeleted()) { |
|
| 33 | 33 | static::getMediaManager()->delete($model); |
| 34 | 34 | } |
| 35 | 35 | }); |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | try { |
| 101 | 101 | // Execute the callable with the temporary file. You also can receive the |
| 102 | 102 | // model instance as second argument. |
| 103 | - Container::getInstance()->call($callback, [$file, $this]); |
|
| 103 | + Container::getInstance()->call($callback, [ $file, $this ]); |
|
| 104 | 104 | } catch (\Exception $ex) { |
| 105 | 105 | // Delete the temporary file wheter it exists. |
| 106 | 106 | File::delete($file->path()); |
@@ -154,8 +154,8 @@ discard block |
||
| 154 | 154 | public function fillUrl(string $url) |
| 155 | 155 | { |
| 156 | 156 | // Fill the url with unguarded permissions. |
| 157 | - static::unguarded(function () use ($url) { |
|
| 158 | - $this->fill([$this->getUrlField() => $url]); |
|
| 157 | + static::unguarded(function() use ($url) { |
|
| 158 | + $this->fill([ $this->getUrlField() => $url ]); |
|
| 159 | 159 | }); |
| 160 | 160 | |
| 161 | 161 | return $this; |
@@ -230,7 +230,7 @@ discard block |
||
| 230 | 230 | $url = $this->{$this->getUrlField()}; |
| 231 | 231 | |
| 232 | 232 | $options = collect($this->getHtmlOptions()) |
| 233 | - ->map(function ($value, $key) { |
|
| 233 | + ->map(function($value, $key) { |
|
| 234 | 234 | if (is_int($key)) { |
| 235 | 235 | $key = $value; |
| 236 | 236 | $value = ''; |
@@ -250,7 +250,7 @@ discard block |
||
| 250 | 250 | */ |
| 251 | 251 | protected function getHtmlOptions() |
| 252 | 252 | { |
| 253 | - return []; |
|
| 253 | + return [ ]; |
|
| 254 | 254 | } |
| 255 | 255 | |
| 256 | 256 | /** |