Completed
Push — dev ( ca0385...1f683f )
by Yan
02:15
created
src/Lincable/UrlCompiler.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
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->parser->isParameterDynamic($fragment)) {
39 39
 
40 40
                 // We assume the parameter fragment is dynamic for
@@ -58,14 +58,14 @@  discard block
 block discarded – undo
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->parser->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->parser->getMatches($parameter);
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
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
     /**
Please login to merge, or discard this patch.
src/Lincable/UrlConf.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 
@@ -143,12 +143,12 @@  discard block
 block discarded – undo
143 143
     {
144 144
         $model = $key;
145 145
 
146
-        if (str_contains($key, '.') || ! str_contains($key, '\\')) {
146
+        if (str_contains($key, '.') || !str_contains($key, '\\')) {
147 147
             
148 148
             // Build the class namespace using the base model namespace
149 149
             // and the parts of the key splitted by dots.
150
-            $model =  $this->buildNamespace(array_merge(
151
-                [$this->modelsNamespace],
150
+            $model = $this->buildNamespace(array_merge(
151
+                [ $this->modelsNamespace ],
152 152
                 array_map('ucfirst', explode('.', $key))
153 153
             ));
154 154
         }
Please login to merge, or discard this patch.
src/Lincable/UrlGenerator.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
      * @param  array $params
76 76
      * @return this
77 77
      */
78
-    public function forModel(Model $model, array $params = [])
78
+    public function forModel(Model $model, array $params = [ ])
79 79
     {
80 80
         // Verify wheter we have the model fully configured on the url configuration.
81 81
         $this->guardModel($model);
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
         // The model class name.
101 101
         $className = get_class($model);
102 102
 
103
-        if (! $this->urlConf->has($className)) {
103
+        if (!$this->urlConf->has($className)) {
104 104
             throw new NoModelConfException("Model [{$className}] is not configured. Check your lincable url configuration.");
105 105
         }
106 106
 
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
      * @param  array $params
116 116
      * @return void
117 117
      */
118
-    protected function setModelFormatters(array $customParams = [])
118
+    protected function setModelFormatters(array $customParams = [ ])
119 119
     {
120 120
         $attributes = $this->getModel()->getAttributes();
121 121
 
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
      */
137 137
     public function generate()
138 138
     {
139
-        return $this->availableParsers->reduce(function ($url, Parser $parser) {
139
+        return $this->availableParsers->reduce(function($url, Parser $parser) {
140 140
 
141 141
             // Set the compiler current parser.
142 142
             $this->compiler->setParser($parser);
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
         $url = $this->getRawUrl();
252 252
 
253 253
         // Get all dynamic parameters on url from model parsers.
254
-        $dynamics = $this->availableParsers->map(function (Parser $parser) use ($url) {
254
+        $dynamics = $this->availableParsers->map(function(Parser $parser) use ($url) {
255 255
 
256 256
             // Set the current parser.
257 257
             $this->compiler->setParser($parser);
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
             return $this->compiler->parseDynamics($url);
260 260
         })->flatten()->all();
261 261
         
262
-        return array_filter($parameters, function ($key) use ($dynamics) {
262
+        return array_filter($parameters, function($key) use ($dynamics) {
263 263
             return in_array($key, $dynamics);
264 264
         }, ARRAY_FILTER_USE_KEY);
265 265
     }
@@ -272,18 +272,18 @@  discard block
 block discarded – undo
272 272
      */
273 273
     protected function injectFormatterToAvailableParsers(array $dynamicParameters)
274 274
     {
275
-        $this->availableParsers->each(function (Parser $parser) use ($dynamicParameters) {
275
+        $this->availableParsers->each(function(Parser $parser) use ($dynamicParameters) {
276 276
             foreach ($dynamicParameters as $key => $value) {
277 277
 
278 278
                 // Register the formatter for the key, and the logic function is to return
279
-                $parser->addFormatter(function () use ($value, $parser) {
279
+                $parser->addFormatter(function() use ($value, $parser) {
280 280
                     if ($this->parameterResolver) {
281 281
 
282 282
                         // Get the container instance on parser class.
283 283
                         $container = $parser->getContainer();
284 284
 
285 285
                         // Call the parameter resolver for the value returned.
286
-                        $value = $container->call($this->parameterResolver, [$value]);
286
+                        $value = $container->call($this->parameterResolver, [ $value ]);
287 287
                     }
288 288
 
289 289
                     return $value;
@@ -303,7 +303,7 @@  discard block
 block discarded – undo
303 303
         $url = $this->getRawUrl();
304 304
 
305 305
         // Get parsers that has dynamic parameters for model url.
306
-        $availableParsers = $this->parsers->filter(function (Parser $parser) use ($url) {
306
+        $availableParsers = $this->parsers->filter(function(Parser $parser) use ($url) {
307 307
 
308 308
             // Change the current compiler parser.
309 309
             $this->compiler->setParser($parser);
Please login to merge, or discard this patch.