Skip to content

Commit b952d5e

Browse files
committed
Cleaned up code.
1 parent 93a013c commit b952d5e

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

src/CacheKey.php

+13-9
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
1-
<?php namespace GeneaLabs\LaravelModelCaching;
1+
<?php
22

3+
namespace GeneaLabs\LaravelModelCaching;
4+
5+
use BackedEnum;
36
use Exception;
47
use GeneaLabs\LaravelModelCaching\Traits\CachePrefixing;
58
use Illuminate\Database\Query\Expression;
69
use Illuminate\Support\Arr;
710
use Illuminate\Support\Collection;
811
use Illuminate\Support\Str;
912
use Ramsey\Uuid\Uuid;
13+
use UnitEnum;
1014

1115
class CacheKey
1216
{
@@ -80,7 +84,7 @@ protected function getColumnClauses(array $where) : string
8084
if ($where["type"] !== "Column") {
8185
return "";
8286
}
83-
87+
8488
if ($where["first"] instanceof Expression) {
8589
$where["first"] = $this->expressionToString($where["first"]);
8690
}
@@ -179,7 +183,7 @@ protected function getOrderByClauses() : string
179183
}
180184

181185
$orders = collect($this->query->orders);
182-
186+
183187
return $orders
184188
->reduce(function ($carry, $order) {
185189
if (($order["type"] ?? "") === "Raw") {
@@ -225,7 +229,7 @@ protected function getQueryColumns(array $columns) : string
225229
if (property_exists($this->query, "columns")
226230
&& $this->query->columns
227231
) {
228-
$columns = array_map(function ($column) {
232+
$columns = array_map(function ($column) {
229233
return $this->expressionToString($column);
230234
}, $this->query->columns);
231235

@@ -350,7 +354,7 @@ protected function getWhereClauses(array $wheres = []) : string
350354
return $value;
351355
});
352356
}
353-
357+
354358
protected function getWheres(array $wheres) : Collection
355359
{
356360
$wheres = collect($wheres);
@@ -384,7 +388,7 @@ protected function getWithModels() : string
384388
return "{$carry}-{$relatedConnection}:{$relatedDatabase}:{$related}";
385389
});
386390
}
387-
391+
388392
protected function recursiveImplode(array $items, string $glue = ",") : string
389393
{
390394
$result = "";
@@ -411,11 +415,11 @@ protected function recursiveImplode(array $items, string $glue = ",") : string
411415
return $result;
412416
}
413417

414-
private function processEnum(\BackedEnum|\UnitEnum|Expression|string $value): string
418+
private function processEnum(BackedEnum|UnitEnum|Expression|string|null $value): ?string
415419
{
416-
if ($value instanceof \BackedEnum) {
420+
if ($value instanceof BackedEnum) {
417421
return $value->value;
418-
} elseif ($value instanceof \UnitEnum) {
422+
} elseif ($value instanceof UnitEnum) {
419423
return $value->name;
420424
} elseif ($value instanceof Expression) {
421425
return $this->expressionToString($value);

0 commit comments

Comments
 (0)