Removed more functional-php usages

This commit is contained in:
Alejandro Celaya
2023-11-30 14:34:21 +01:00
parent 549c6605f0
commit bff4bd12ae
20 changed files with 156 additions and 91 deletions

View File

@@ -4,8 +4,9 @@ declare(strict_types=1);
namespace Shlinkio\Shlink\Rest;
use function array_filter;
use function array_map;
use function Functional\first;
use function reset;
use function Shlinkio\Shlink\Config\loadConfigFromGlob;
use function sprintf;
@@ -34,8 +35,9 @@ class ConfigProvider
private static function buildUnversionedHealthRouteFromExistingRoutes(array $routes): ?array
{
$healthRoute = first($routes, fn (array $route) => $route['path'] === '/health');
if ($healthRoute === null) {
$healthRoutes = array_filter($routes, fn (array $route) => $route['path'] === '/health');
$healthRoute = reset($healthRoutes);
if ($healthRoute === false) {
return null;
}

View File

@@ -15,8 +15,8 @@ use Shlinkio\Shlink\Core\Exception\TagConflictException;
use Shlinkio\Shlink\Core\Exception\TagNotFoundException;
use Shlinkio\Shlink\Core\Exception\ValidationException;
use function end;
use function explode;
use function Functional\last;
/** @deprecated */
class BackwardsCompatibleProblemDetailsException extends RuntimeException implements ProblemDetailsExceptionInterface
@@ -77,7 +77,9 @@ class BackwardsCompatibleProblemDetailsException extends RuntimeException implem
private function remapType(string $wrappedType): string
{
$lastSegment = last(explode('/', $wrappedType));
$segments = explode('/', $wrappedType);
$lastSegment = end($segments);
return match ($lastSegment) {
ValidationException::ERROR_CODE => 'INVALID_ARGUMENT',
DeleteShortUrlException::ERROR_CODE => 'INVALID_SHORT_URL_DELETION',