From 8e1cd67a3d810d97325e79a972137690c7d47796 Mon Sep 17 00:00:00 2001
From: Alejandro Celaya <alejandro@alejandrocelaya.com>
Date: Sat, 1 Jan 2022 18:40:48 +0100
Subject: [PATCH] Simplified some match expressions

---
 config/autoload/entity-manager.global.php | 4 ++--
 config/autoload/redis.global.php          | 4 ++--
 module/Core/src/Visit/RequestTracker.php  | 7 +++----
 module/Rest/src/Service/ApiKeyService.php | 2 +-
 4 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/config/autoload/entity-manager.global.php b/config/autoload/entity-manager.global.php
index 08427898..c67809d2 100644
--- a/config/autoload/entity-manager.global.php
+++ b/config/autoload/entity-manager.global.php
@@ -21,8 +21,8 @@ return (static function (): array {
         'mssql' => '1433',
         default => '3306',
     };
-    $resolveConnection = static fn () => match (true) {
-        $driver === null || $driver === 'sqlite' => [
+    $resolveConnection = static fn () => match ($driver) {
+        null, 'sqlite' => [
             'driver' => 'pdo_sqlite',
             'path' => 'data/database.sqlite',
         ],
diff --git a/config/autoload/redis.global.php b/config/autoload/redis.global.php
index 22101b65..fbcb5846 100644
--- a/config/autoload/redis.global.php
+++ b/config/autoload/redis.global.php
@@ -7,8 +7,8 @@ use function Shlinkio\Shlink\Common\env;
 return (static function (): array {
     $redisServers = env('REDIS_SERVERS');
 
-    return match (true) {
-        $redisServers === null => [],
+    return match ($redisServers) {
+        null => [],
         default => [
             'cache' => [
                 'redis' => [
diff --git a/module/Core/src/Visit/RequestTracker.php b/module/Core/src/Visit/RequestTracker.php
index 7cefa8a2..dc45e12f 100644
--- a/module/Core/src/Visit/RequestTracker.php
+++ b/module/Core/src/Visit/RequestTracker.php
@@ -83,10 +83,9 @@ class RequestTracker implements RequestTrackerInterface, RequestMethodInterface
         $disableTrackingFrom = $this->trackingOptions->disableTrackingFrom();
 
         return some($disableTrackingFrom, function (string $value) use ($ip, $remoteAddrParts): bool {
-            $range = match (true) {
-                str_contains($value, '*') => $this->parseValueWithWildcards($value, $remoteAddrParts),
-                default => Factory::parseRangeString($value),
-            };
+            $range = str_contains($value, '*')
+                ? $this->parseValueWithWildcards($value, $remoteAddrParts)
+                : Factory::parseRangeString($value);
 
             return $range !== null && $ip->matches($range);
         });
diff --git a/module/Rest/src/Service/ApiKeyService.php b/module/Rest/src/Service/ApiKeyService.php
index d66e70e2..7d7e0710 100644
--- a/module/Rest/src/Service/ApiKeyService.php
+++ b/module/Rest/src/Service/ApiKeyService.php
@@ -41,7 +41,7 @@ class ApiKeyService implements ApiKeyServiceInterface
             $expirationDate !== null && $name !== null => ApiKey::fromMeta(
                 ApiKeyMeta::withNameAndExpirationDate($name, $expirationDate),
             ),
-            $expirationDate !== null =>  ApiKey::fromMeta(ApiKeyMeta::withExpirationDate($expirationDate)),
+            $expirationDate !== null => ApiKey::fromMeta(ApiKeyMeta::withExpirationDate($expirationDate)),
             $name !== null => ApiKey::fromMeta(ApiKeyMeta::withName($name)),
             default => ApiKey::create(),
         };