mirror of
https://github.com/shlinkio/shlink.git
synced 2025-02-25 18:45:27 -06:00
Simplified some match expressions
This commit is contained in:
parent
18b4caa55e
commit
8e1cd67a3d
@ -21,8 +21,8 @@ return (static function (): array {
|
|||||||
'mssql' => '1433',
|
'mssql' => '1433',
|
||||||
default => '3306',
|
default => '3306',
|
||||||
};
|
};
|
||||||
$resolveConnection = static fn () => match (true) {
|
$resolveConnection = static fn () => match ($driver) {
|
||||||
$driver === null || $driver === 'sqlite' => [
|
null, 'sqlite' => [
|
||||||
'driver' => 'pdo_sqlite',
|
'driver' => 'pdo_sqlite',
|
||||||
'path' => 'data/database.sqlite',
|
'path' => 'data/database.sqlite',
|
||||||
],
|
],
|
||||||
|
@ -7,8 +7,8 @@ use function Shlinkio\Shlink\Common\env;
|
|||||||
return (static function (): array {
|
return (static function (): array {
|
||||||
$redisServers = env('REDIS_SERVERS');
|
$redisServers = env('REDIS_SERVERS');
|
||||||
|
|
||||||
return match (true) {
|
return match ($redisServers) {
|
||||||
$redisServers === null => [],
|
null => [],
|
||||||
default => [
|
default => [
|
||||||
'cache' => [
|
'cache' => [
|
||||||
'redis' => [
|
'redis' => [
|
||||||
|
@ -83,10 +83,9 @@ class RequestTracker implements RequestTrackerInterface, RequestMethodInterface
|
|||||||
$disableTrackingFrom = $this->trackingOptions->disableTrackingFrom();
|
$disableTrackingFrom = $this->trackingOptions->disableTrackingFrom();
|
||||||
|
|
||||||
return some($disableTrackingFrom, function (string $value) use ($ip, $remoteAddrParts): bool {
|
return some($disableTrackingFrom, function (string $value) use ($ip, $remoteAddrParts): bool {
|
||||||
$range = match (true) {
|
$range = str_contains($value, '*')
|
||||||
str_contains($value, '*') => $this->parseValueWithWildcards($value, $remoteAddrParts),
|
? $this->parseValueWithWildcards($value, $remoteAddrParts)
|
||||||
default => Factory::parseRangeString($value),
|
: Factory::parseRangeString($value);
|
||||||
};
|
|
||||||
|
|
||||||
return $range !== null && $ip->matches($range);
|
return $range !== null && $ip->matches($range);
|
||||||
});
|
});
|
||||||
|
@ -41,7 +41,7 @@ class ApiKeyService implements ApiKeyServiceInterface
|
|||||||
$expirationDate !== null && $name !== null => ApiKey::fromMeta(
|
$expirationDate !== null && $name !== null => ApiKey::fromMeta(
|
||||||
ApiKeyMeta::withNameAndExpirationDate($name, $expirationDate),
|
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)),
|
$name !== null => ApiKey::fromMeta(ApiKeyMeta::withName($name)),
|
||||||
default => ApiKey::create(),
|
default => ApiKey::create(),
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user