@@ -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 | /** |
@@ -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 | } |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | * @param array $params |
| 80 | 80 | * @return this |
| 81 | 81 | */ |
| 82 | - public function forModel(Model $model, array $params = []) |
|
| 82 | + public function forModel(Model $model, array $params = [ ]) |
|
| 83 | 83 | { |
| 84 | 84 | // Verify wheter we have the model fully configured on the url configuration. |
| 85 | 85 | $this->guardModel($model); |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | // The model class name. |
| 105 | 105 | $className = get_class($model); |
| 106 | 106 | |
| 107 | - if (! $this->urlConf->has($className)) { |
|
| 107 | + if (!$this->urlConf->has($className)) { |
|
| 108 | 108 | throw new NoModelConfException("Model [{$className}] is not configured. Check your lincable url configuration."); |
| 109 | 109 | } |
| 110 | 110 | |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | * @param array $params |
| 120 | 120 | * @return void |
| 121 | 121 | */ |
| 122 | - protected function setModelFormatters(array $customParams = []) |
|
| 122 | + protected function setModelFormatters(array $customParams = [ ]) |
|
| 123 | 123 | { |
| 124 | 124 | $attributes = $this->getModel()->getAttributes(); |
| 125 | 125 | |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | */ |
| 141 | 141 | public function generate() |
| 142 | 142 | { |
| 143 | - return $this->availableParsers->reduce(function ($url, Parser $parser) { |
|
| 143 | + return $this->availableParsers->reduce(function($url, Parser $parser) { |
|
| 144 | 144 | |
| 145 | 145 | // Set the compiler current parser. |
| 146 | 146 | $this->compiler->setParser($parser); |
@@ -268,7 +268,7 @@ discard block |
||
| 268 | 268 | $url = $this->getRawUrl(); |
| 269 | 269 | |
| 270 | 270 | // Get all dynamic parameters on url from model parsers. |
| 271 | - $dynamics = $this->availableParsers->map(function (Parser $parser) use ($url) { |
|
| 271 | + $dynamics = $this->availableParsers->map(function(Parser $parser) use ($url) { |
|
| 272 | 272 | |
| 273 | 273 | // Set the current parser. |
| 274 | 274 | $this->compiler->setParser($parser); |
@@ -276,7 +276,7 @@ discard block |
||
| 276 | 276 | return $this->compiler->parseDynamics($url); |
| 277 | 277 | })->flatten()->all(); |
| 278 | 278 | |
| 279 | - return array_filter($parameters, function ($key) use ($dynamics) { |
|
| 279 | + return array_filter($parameters, function($key) use ($dynamics) { |
|
| 280 | 280 | return in_array($key, $dynamics); |
| 281 | 281 | }, ARRAY_FILTER_USE_KEY); |
| 282 | 282 | } |
@@ -289,18 +289,18 @@ discard block |
||
| 289 | 289 | */ |
| 290 | 290 | protected function injectFormatterToAvailableParsers(array $dynamicParameters) |
| 291 | 291 | { |
| 292 | - $this->availableParsers->each(function (Parser $parser) use ($dynamicParameters) { |
|
| 292 | + $this->availableParsers->each(function(Parser $parser) use ($dynamicParameters) { |
|
| 293 | 293 | foreach ($dynamicParameters as $key => $value) { |
| 294 | 294 | |
| 295 | 295 | // Register the formatter for the key, and the logic function is to return |
| 296 | - $parser->addFormatter(function () use ($value, $key, $parser) { |
|
| 296 | + $parser->addFormatter(function() use ($value, $key, $parser) { |
|
| 297 | 297 | if (static::$parameterResolver) { |
| 298 | 298 | |
| 299 | 299 | // Get the container instance on parser class. |
| 300 | 300 | $container = $parser->getContainer(); |
| 301 | 301 | |
| 302 | 302 | // Call the parameter resolver for the value returned. |
| 303 | - $value = $container->call(static::$parameterResolver, [$value, $key]); |
|
| 303 | + $value = $container->call(static::$parameterResolver, [ $value, $key ]); |
|
| 304 | 304 | } |
| 305 | 305 | |
| 306 | 306 | return $value; |
@@ -320,7 +320,7 @@ discard block |
||
| 320 | 320 | $url = $this->getRawUrl(); |
| 321 | 321 | |
| 322 | 322 | // Get parsers that has dynamic parameters for model url. |
| 323 | - $availableParsers = $this->parsers->filter(function (Parser $parser) use ($url) { |
|
| 323 | + $availableParsers = $this->parsers->filter(function(Parser $parser) use ($url) { |
|
| 324 | 324 | |
| 325 | 325 | // Change the current compiler parser. |
| 326 | 326 | $this->compiler->setParser($parser); |
@@ -60,7 +60,7 @@ |
||
| 60 | 60 | | |
| 61 | 61 | */ |
| 62 | 62 | |
| 63 | - 'upload_headers' => [], |
|
| 63 | + 'upload_headers' => [ ], |
|
| 64 | 64 | |
| 65 | 65 | /* |
| 66 | 66 | |-------------------------------------------------------------------------- |
@@ -32,7 +32,7 @@ discard block |
||
| 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 | } |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | { |
| 48 | 48 | if ($model->isClone()) { |
| 49 | 49 | \Event::fakeFor( |
| 50 | - function () use ($model) { |
|
| 50 | + function() use ($model) { |
|
| 51 | 51 | static::getMediaManager()->copy( |
| 52 | 52 | $model->getSourceModel(), |
| 53 | 53 | $model, |