mirror of
https://github.com/shlinkio/shlink.git
synced 2026-03-08 08:13:11 +08:00
Replaced all FQ global function and constants by explicit imports
This commit is contained in:
@@ -7,6 +7,7 @@ use Psr\Http\Message\ResponseInterface as Response;
|
||||
use Psr\Http\Message\ServerRequestInterface as Request;
|
||||
use Psr\Http\Server\MiddlewareInterface;
|
||||
use Psr\Http\Server\RequestHandlerInterface;
|
||||
use function strpos;
|
||||
|
||||
class PathVersionMiddleware implements MiddlewareInterface
|
||||
{
|
||||
@@ -26,7 +27,7 @@ class PathVersionMiddleware implements MiddlewareInterface
|
||||
$path = $uri->getPath();
|
||||
|
||||
// If the path does not begin with the version number, prepend v1 by default for BC compatibility purposes
|
||||
if (\strpos($path, '/v') !== 0) {
|
||||
if (strpos($path, '/v') !== 0) {
|
||||
$request = $request->withUri($uri->withPath('/v1' . $uri->getPath()));
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,10 @@ use Psr\Http\Server\MiddlewareInterface;
|
||||
use Psr\Http\Server\RequestHandlerInterface;
|
||||
use Zend\Diactoros\Response;
|
||||
use Zend\Diactoros\Response\JsonResponse;
|
||||
use function array_shift;
|
||||
use function explode;
|
||||
use function strpos;
|
||||
use function strtolower;
|
||||
|
||||
class CreateShortUrlContentNegotiationMiddleware implements MiddlewareInterface
|
||||
{
|
||||
@@ -54,15 +58,15 @@ class CreateShortUrlContentNegotiationMiddleware implements MiddlewareInterface
|
||||
return self::JSON;
|
||||
}
|
||||
|
||||
$format = \strtolower((string) $query['format']);
|
||||
$format = strtolower((string) $query['format']);
|
||||
return $format === 'txt' ? self::PLAIN_TEXT : self::JSON;
|
||||
}
|
||||
|
||||
private function determineAcceptTypeFromHeader(string $acceptValue): string
|
||||
{
|
||||
$accepts = \explode(',', $acceptValue);
|
||||
$accept = \strtolower(\array_shift($accepts));
|
||||
return \strpos($accept, 'text/plain') !== false ? self::PLAIN_TEXT : self::JSON;
|
||||
$accepts = explode(',', $acceptValue);
|
||||
$accept = strtolower(array_shift($accepts));
|
||||
return strpos($accept, 'text/plain') !== false ? self::PLAIN_TEXT : self::JSON;
|
||||
}
|
||||
|
||||
private function determineBody(JsonResponse $resp): string
|
||||
|
||||
@@ -7,6 +7,7 @@ use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Psr\Http\Server\MiddlewareInterface;
|
||||
use Psr\Http\Server\RequestHandlerInterface;
|
||||
use function str_replace;
|
||||
|
||||
class ShortCodePathMiddleware implements MiddlewareInterface
|
||||
{
|
||||
@@ -24,7 +25,7 @@ class ShortCodePathMiddleware implements MiddlewareInterface
|
||||
|
||||
// If the path starts with the old prefix, replace it by the new one
|
||||
return $handler->handle(
|
||||
$request->withUri($uri->withPath(\str_replace(self::OLD_PATH_PREFIX, self::NEW_PATH_PREFIX, $path)))
|
||||
$request->withUri($uri->withPath(str_replace(self::OLD_PATH_PREFIX, self::NEW_PATH_PREFIX, $path)))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user