@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | |
| 54 | 54 | protected function getBindingsSlug() : string |
| 55 | 55 | { |
| 56 | - if (! method_exists($this->model, 'query')) { |
|
| 56 | + if (!method_exists($this->model, 'query')) { |
|
| 57 | 57 | return ''; |
| 58 | 58 | } |
| 59 | 59 | |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | |
| 82 | 82 | protected function getInAndNotInClauses(array $where) : string |
| 83 | 83 | { |
| 84 | - if (! in_array($where["type"], ["In", "NotIn", "InRaw"])) { |
|
| 84 | + if (!in_array($where["type"], ["In", "NotIn", "InRaw"])) { |
|
| 85 | 85 | return ""; |
| 86 | 86 | } |
| 87 | 87 | |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | $this->currentBinding += count($where["values"]); |
| 94 | 94 | } |
| 95 | 95 | |
| 96 | - if (! is_numeric($subquery) && ! is_numeric(str_replace("_", "", $subquery))) { |
|
| 96 | + if (!is_numeric($subquery) && !is_numeric(str_replace("_", "", $subquery))) { |
|
| 97 | 97 | try { |
| 98 | 98 | $subquery = Uuid::fromBytes($subquery); |
| 99 | 99 | $values = $this->recursiveImplode([$subquery], "_"); |
@@ -113,8 +113,8 @@ discard block |
||
| 113 | 113 | |
| 114 | 114 | protected function getLimitClause() : string |
| 115 | 115 | { |
| 116 | - if (! property_exists($this->query, "limit") |
|
| 117 | - || ! $this->query->limit |
|
| 116 | + if (!property_exists($this->query, "limit") |
|
| 117 | + || !$this->query->limit |
|
| 118 | 118 | ) { |
| 119 | 119 | return ""; |
| 120 | 120 | } |
@@ -129,17 +129,17 @@ discard block |
||
| 129 | 129 | |
| 130 | 130 | protected function getNestedClauses(array $where) : string |
| 131 | 131 | { |
| 132 | - if (! in_array($where["type"], ["Exists", "Nested", "NotExists"])) { |
|
| 132 | + if (!in_array($where["type"], ["Exists", "Nested", "NotExists"])) { |
|
| 133 | 133 | return ""; |
| 134 | 134 | } |
| 135 | 135 | |
| 136 | - return "-" . strtolower($where["type"]) . $this->getWhereClauses($where["query"]->wheres); |
|
| 136 | + return "-".strtolower($where["type"]).$this->getWhereClauses($where["query"]->wheres); |
|
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | protected function getOffsetClause() : string |
| 140 | 140 | { |
| 141 | - if (! property_exists($this->query, "offset") |
|
| 142 | - || ! $this->query->offset |
|
| 141 | + if (!property_exists($this->query, "offset") |
|
| 142 | + || !$this->query->offset |
|
| 143 | 143 | ) { |
| 144 | 144 | return ""; |
| 145 | 145 | } |
@@ -149,8 +149,8 @@ discard block |
||
| 149 | 149 | |
| 150 | 150 | protected function getOrderByClauses() : string |
| 151 | 151 | { |
| 152 | - if (! property_exists($this->query, "orders") |
|
| 153 | - || ! $this->query->orders |
|
| 152 | + if (!property_exists($this->query, "orders") |
|
| 153 | + || !$this->query->orders |
|
| 154 | 154 | ) { |
| 155 | 155 | return ""; |
| 156 | 156 | } |
@@ -158,12 +158,12 @@ discard block |
||
| 158 | 158 | $orders = collect($this->query->orders); |
| 159 | 159 | |
| 160 | 160 | return $orders |
| 161 | - ->reduce(function ($carry, $order) { |
|
| 161 | + ->reduce(function($carry, $order) { |
|
| 162 | 162 | if (($order["type"] ?? "") === "Raw") { |
| 163 | - return $carry . "_orderByRaw_" . (new Str)->slug($order["sql"]); |
|
| 163 | + return $carry."_orderByRaw_".(new Str)->slug($order["sql"]); |
|
| 164 | 164 | } |
| 165 | 165 | |
| 166 | - return $carry . "_orderBy_" . $order["column"] . "_" . $order["direction"]; |
|
| 166 | + return $carry."_orderBy_".$order["column"]."_".$order["direction"]; |
|
| 167 | 167 | }) |
| 168 | 168 | ?: ""; |
| 169 | 169 | } |
@@ -184,8 +184,8 @@ discard block |
||
| 184 | 184 | { |
| 185 | 185 | if (($columns === ["*"] |
| 186 | 186 | || $columns === []) |
| 187 | - && (! property_exists($this->query, "columns") |
|
| 188 | - || ! $this->query->columns) |
|
| 187 | + && (!property_exists($this->query, "columns") |
|
| 188 | + || !$this->query->columns) |
|
| 189 | 189 | ) { |
| 190 | 190 | return ""; |
| 191 | 191 | } |
@@ -193,15 +193,15 @@ discard block |
||
| 193 | 193 | if (property_exists($this->query, "columns") |
| 194 | 194 | && $this->query->columns |
| 195 | 195 | ) { |
| 196 | - return "_" . implode("_", $this->query->columns); |
|
| 196 | + return "_".implode("_", $this->query->columns); |
|
| 197 | 197 | } |
| 198 | 198 | |
| 199 | - return "_" . implode("_", $columns); |
|
| 199 | + return "_".implode("_", $columns); |
|
| 200 | 200 | } |
| 201 | 201 | |
| 202 | 202 | protected function getRawClauses(array $where) : string |
| 203 | 203 | { |
| 204 | - if (! in_array($where["type"], ["raw"])) { |
|
| 204 | + if (!in_array($where["type"], ["raw"])) { |
|
| 205 | 205 | return ""; |
| 206 | 206 | } |
| 207 | 207 | |
@@ -209,7 +209,7 @@ discard block |
||
| 209 | 209 | $clause = "_{$where["boolean"]}"; |
| 210 | 210 | |
| 211 | 211 | while (count($queryParts) > 1) { |
| 212 | - $clause .= "_" . array_shift($queryParts); |
|
| 212 | + $clause .= "_".array_shift($queryParts); |
|
| 213 | 213 | $clause .= $this->getCurrentBinding("where"); |
| 214 | 214 | $this->currentBinding++; |
| 215 | 215 | } |
@@ -217,10 +217,10 @@ discard block |
||
| 217 | 217 | $lastPart = array_shift($queryParts); |
| 218 | 218 | |
| 219 | 219 | if ($lastPart) { |
| 220 | - $clause .= "_" . $lastPart; |
|
| 220 | + $clause .= "_".$lastPart; |
|
| 221 | 221 | } |
| 222 | 222 | |
| 223 | - return "-" . str_replace(" ", "_", $clause); |
|
| 223 | + return "-".str_replace(" ", "_", $clause); |
|
| 224 | 224 | } |
| 225 | 225 | |
| 226 | 226 | protected function getTableSlug() : string |
@@ -240,7 +240,7 @@ discard block |
||
| 240 | 240 | |
| 241 | 241 | protected function getValuesClause(array $where = []) : string |
| 242 | 242 | { |
| 243 | - if (! $where |
|
| 243 | + if (!$where |
|
| 244 | 244 | || in_array($where["type"], ["NotNull", "Null"]) |
| 245 | 245 | ) { |
| 246 | 246 | return ""; |
@@ -249,7 +249,7 @@ discard block |
||
| 249 | 249 | $values = $this->getValuesFromWhere($where); |
| 250 | 250 | $values = $this->getValuesFromBindings($where, $values); |
| 251 | 251 | |
| 252 | - return "_" . $values; |
|
| 252 | + return "_".$values; |
|
| 253 | 253 | } |
| 254 | 254 | |
| 255 | 255 | protected function getValuesFromWhere(array $where) : string |
@@ -274,7 +274,7 @@ discard block |
||
| 274 | 274 | |
| 275 | 275 | protected function getValuesFromBindings(array $where, string $values) : string |
| 276 | 276 | { |
| 277 | - $bindingFallback = __CLASS__ . ':UNKNOWN_BINDING'; |
|
| 277 | + $bindingFallback = __CLASS__.':UNKNOWN_BINDING'; |
|
| 278 | 278 | $currentBinding = $this->getCurrentBinding("where", $bindingFallback); |
| 279 | 279 | |
| 280 | 280 | if ($currentBinding !== $bindingFallback) { |
@@ -282,7 +282,7 @@ discard block |
||
| 282 | 282 | $this->currentBinding++; |
| 283 | 283 | |
| 284 | 284 | if ($where["type"] === "between") { |
| 285 | - $values .= "_" . $this->getCurrentBinding("where"); |
|
| 285 | + $values .= "_".$this->getCurrentBinding("where"); |
|
| 286 | 286 | $this->currentBinding++; |
| 287 | 287 | } |
| 288 | 288 | } |
@@ -298,8 +298,8 @@ discard block |
||
| 298 | 298 | |
| 299 | 299 | protected function getWhereClauses(array $wheres = []) : string |
| 300 | 300 | { |
| 301 | - return "" . $this->getWheres($wheres) |
|
| 302 | - ->reduce(function ($carry, $where) { |
|
| 301 | + return "".$this->getWheres($wheres) |
|
| 302 | + ->reduce(function($carry, $where) { |
|
| 303 | 303 | $value = $carry; |
| 304 | 304 | $value .= $this->getNestedClauses($where); |
| 305 | 305 | $value .= $this->getColumnClauses($where); |
@@ -332,8 +332,8 @@ discard block |
||
| 332 | 332 | return ""; |
| 333 | 333 | } |
| 334 | 334 | |
| 335 | - return $eagerLoads->keys()->reduce(function ($carry, $related) { |
|
| 336 | - if (! method_exists($this->model, $related)) { |
|
| 335 | + return $eagerLoads->keys()->reduce(function($carry, $related) { |
|
| 336 | + if (!method_exists($this->model, $related)) { |
|
| 337 | 337 | return "{$carry}-{$related}"; |
| 338 | 338 | } |
| 339 | 339 | |
@@ -365,7 +365,7 @@ discard block |
||
| 365 | 365 | continue; |
| 366 | 366 | } |
| 367 | 367 | |
| 368 | - $result .= $glue . $value; |
|
| 368 | + $result .= $glue.$value; |
|
| 369 | 369 | } |
| 370 | 370 | |
| 371 | 371 | return $result; |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | $this->actingAs($user); |
| 112 | 112 | $authorsA = (new AuthorBeginsWithScoped) |
| 113 | 113 | ->all() |
| 114 | - ->map(function ($author) { |
|
| 114 | + ->map(function($author) { |
|
| 115 | 115 | return (new Str)->substr($author->name, 0, 1); |
| 116 | 116 | }) |
| 117 | 117 | ->unique(); |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | $this->actingAs($user); |
| 120 | 120 | $authorsB = (new AuthorBeginsWithScoped) |
| 121 | 121 | ->all() |
| 122 | - ->map(function ($author) { |
|
| 122 | + ->map(function($author) { |
|
| 123 | 123 | return (new Str)->substr($author->name, 0, 1); |
| 124 | 124 | }) |
| 125 | 125 | ->unique(); |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | $this->actingAs($user); |
| 138 | 138 | $authorsA = (new AuthorBeginsWithScoped) |
| 139 | 139 | ->get() |
| 140 | - ->map(function ($author) { |
|
| 140 | + ->map(function($author) { |
|
| 141 | 141 | return (new Str)->substr($author->name, 0, 1); |
| 142 | 142 | }) |
| 143 | 143 | ->unique(); |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | $this->actingAs($user); |
| 146 | 146 | $authorsB = (new AuthorBeginsWithScoped) |
| 147 | 147 | ->get() |
| 148 | - ->map(function ($author) { |
|
| 148 | + ->map(function($author) { |
|
| 149 | 149 | return (new Str)->substr($author->name, 0, 1); |
| 150 | 150 | }) |
| 151 | 151 | ->unique(); |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | $authorsA = (new AuthorBeginsWithScoped) |
| 165 | 165 | ->withoutGlobalScopes() |
| 166 | 166 | ->get() |
| 167 | - ->map(function ($author) { |
|
| 167 | + ->map(function($author) { |
|
| 168 | 168 | return (new Str)->substr($author->name, 0, 1); |
| 169 | 169 | }) |
| 170 | 170 | ->unique(); |
@@ -173,7 +173,7 @@ discard block |
||
| 173 | 173 | $authorsB = (new AuthorBeginsWithScoped) |
| 174 | 174 | ->withoutGlobalScopes(['GeneaLabs\LaravelModelCaching\Tests\Fixtures\Scopes\NameBeginsWith']) |
| 175 | 175 | ->get() |
| 176 | - ->map(function ($author) { |
|
| 176 | + ->map(function($author) { |
|
| 177 | 177 | return (new Str)->substr($author->name, 0, 1); |
| 178 | 178 | }) |
| 179 | 179 | ->unique(); |
@@ -190,7 +190,7 @@ discard block |
||
| 190 | 190 | $authorsA = (new AuthorBeginsWithScoped) |
| 191 | 191 | ->withoutGlobalScope('GeneaLabs\LaravelModelCaching\Tests\Fixtures\Scopes\NameBeginsWith') |
| 192 | 192 | ->get() |
| 193 | - ->map(function ($author) { |
|
| 193 | + ->map(function($author) { |
|
| 194 | 194 | return (new Str)->substr($author->name, 0, 1); |
| 195 | 195 | }) |
| 196 | 196 | ->unique(); |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | $authorsB = (new AuthorBeginsWithScoped) |
| 200 | 200 | ->withoutGlobalScope('GeneaLabs\LaravelModelCaching\Tests\Fixtures\Scopes\NameBeginsWith') |
| 201 | 201 | ->get() |
| 202 | - ->map(function ($author) { |
|
| 202 | + ->map(function($author) { |
|
| 203 | 203 | return (new Str)->substr($author->name, 0, 1); |
| 204 | 204 | }) |
| 205 | 205 | ->unique(); |
@@ -213,13 +213,13 @@ discard block |
||
| 213 | 213 | $first = "A"; |
| 214 | 214 | $second = "B"; |
| 215 | 215 | $authors1 = (new Author) |
| 216 | - ->with(['books' => static function (HasMany $model) use ($first) { |
|
| 216 | + ->with(['books' => static function(HasMany $model) use ($first) { |
|
| 217 | 217 | $model->startsWith($first); |
| 218 | 218 | }]) |
| 219 | 219 | ->get(); |
| 220 | 220 | $authors2 = (new Author) |
| 221 | 221 | ->disableModelCaching() |
| 222 | - ->with(['books' => static function (HasMany $model) use ($second) { |
|
| 222 | + ->with(['books' => static function(HasMany $model) use ($second) { |
|
| 223 | 223 | $model->startsWith($second); |
| 224 | 224 | }]) |
| 225 | 225 | ->get(); |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | |
| 46 | 46 | protected function applyScopesToInstance() |
| 47 | 47 | { |
| 48 | - if (! property_exists($this, "scopes") |
|
| 48 | + if (!property_exists($this, "scopes") |
|
| 49 | 49 | || $this->scopesAreApplied |
| 50 | 50 | || $this->withoutAllGlobalScopes |
| 51 | 51 | ) { |
@@ -53,11 +53,11 @@ discard block |
||
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | foreach ($this->scopes as $identifier => $scope) { |
| 56 | - if (! isset($this->scopes[$identifier]) || isset($this->withoutGlobalScopes[$identifier])) { |
|
| 56 | + if (!isset($this->scopes[$identifier]) || isset($this->withoutGlobalScopes[$identifier])) { |
|
| 57 | 57 | continue; |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | - $this->callScope(function () use ($scope) { |
|
| 60 | + $this->callScope(function() use ($scope) { |
|
| 61 | 61 | if ($scope instanceof Closure) { |
| 62 | 62 | $scope($this); |
| 63 | 63 | } |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | $cacheKey = "{$cachePrefix}:{$modelClassName}-cooldown:saved-at"; |
| 116 | 116 | |
| 117 | 117 | $this->cache() |
| 118 | - ->rememberForever($cacheKey, function () { |
|
| 118 | + ->rememberForever($cacheKey, function() { |
|
| 119 | 119 | return (new Carbon)->now(); |
| 120 | 120 | }); |
| 121 | 121 | } |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | |
| 193 | 193 | public function getModelCacheCooldown(Model $instance) : array |
| 194 | 194 | { |
| 195 | - if (! $instance->cacheCooldownSeconds) { |
|
| 195 | + if (!$instance->cacheCooldownSeconds) { |
|
| 196 | 196 | return [null, null, null]; |
| 197 | 197 | } |
| 198 | 198 | |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | [$cacheCooldown, $invalidatedAt, $savedAt] = $this |
| 202 | 202 | ->getCacheCooldownDetails($instance, $cachePrefix, $modelClassName); |
| 203 | 203 | |
| 204 | - if (! $cacheCooldown || $cacheCooldown === 0) { |
|
| 204 | + if (!$cacheCooldown || $cacheCooldown === 0) { |
|
| 205 | 205 | return [null, null, null]; |
| 206 | 206 | } |
| 207 | 207 | |
@@ -230,7 +230,7 @@ discard block |
||
| 230 | 230 | { |
| 231 | 231 | [$cacheCooldown, $invalidatedAt] = $this->getModelCacheCooldown($instance); |
| 232 | 232 | |
| 233 | - if (! $cacheCooldown |
|
| 233 | + if (!$cacheCooldown |
|
| 234 | 234 | || (new Carbon)->now()->diffInSeconds($invalidatedAt) < $cacheCooldown |
| 235 | 235 | ) { |
| 236 | 236 | return; |
@@ -255,7 +255,7 @@ discard block |
||
| 255 | 255 | { |
| 256 | 256 | [$cacheCooldown, $invalidatedAt] = $instance->getModelCacheCooldown($instance); |
| 257 | 257 | |
| 258 | - if (! $cacheCooldown) { |
|
| 258 | + if (!$cacheCooldown) { |
|
| 259 | 259 | $instance->flushCache(); |
| 260 | 260 | |
| 261 | 261 | if ($relationship) { |
@@ -282,7 +282,7 @@ discard block |
||
| 282 | 282 | |
| 283 | 283 | public function isCachable() : bool |
| 284 | 284 | { |
| 285 | - $isCacheDisabled = ! Container::getInstance() |
|
| 285 | + $isCacheDisabled = !Container::getInstance() |
|
| 286 | 286 | ->make("config") |
| 287 | 287 | ->get("laravel-model-caching.enabled"); |
| 288 | 288 | $allRelationshipsAreCachable = true; |
@@ -293,8 +293,8 @@ discard block |
||
| 293 | 293 | $allRelationshipsAreCachable = collect($this |
| 294 | 294 | ->eagerLoad) |
| 295 | 295 | ->keys() |
| 296 | - ->reduce(function ($carry, $related) { |
|
| 297 | - if (! method_exists($this->model, $related) |
|
| 296 | + ->reduce(function($carry, $related) { |
|
| 297 | + if (!method_exists($this->model, $related) |
|
| 298 | 298 | || $carry === false |
| 299 | 299 | ) { |
| 300 | 300 | return $carry; |
@@ -302,8 +302,8 @@ discard block |
||
| 302 | 302 | |
| 303 | 303 | $relatedModel = $this->model->$related()->getRelated(); |
| 304 | 304 | |
| 305 | - if (! method_exists($relatedModel, "isCachable") |
|
| 306 | - || ! $relatedModel->isCachable() |
|
| 305 | + if (!method_exists($relatedModel, "isCachable") |
|
| 306 | + || !$relatedModel->isCachable() |
|
| 307 | 307 | ) { |
| 308 | 308 | return false; |
| 309 | 309 | } |
@@ -314,7 +314,7 @@ discard block |
||
| 314 | 314 | } |
| 315 | 315 | |
| 316 | 316 | return $this->isCachable |
| 317 | - && ! $isCacheDisabled |
|
| 317 | + && !$isCacheDisabled |
|
| 318 | 318 | && $allRelationshipsAreCachable; |
| 319 | 319 | } |
| 320 | 320 | |
@@ -325,7 +325,7 @@ discard block |
||
| 325 | 325 | $cacheKey = "{$cachePrefix}:{$modelClassName}-cooldown:saved-at"; |
| 326 | 326 | |
| 327 | 327 | $instance->cache() |
| 328 | - ->rememberForever($cacheKey, function () { |
|
| 328 | + ->rememberForever($cacheKey, function() { |
|
| 329 | 329 | return (new Carbon)->now(); |
| 330 | 330 | }); |
| 331 | 331 | } |