@@ -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 | } |
@@ -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 | |-------------------------------------------------------------------------- |