aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/Route
diff options
context:
space:
mode:
authorHamid Dehnavi <hamid.dev.pro@gmail.com>2023-07-07 04:54:20 +0330
committerHamid Dehnavi <hamid.dev.pro@gmail.com>2023-07-07 04:54:20 +0330
commitd0b20534b94d0295472ab22157a2bc4c2c9fb703 (patch)
tree11778f60be448d4a2eb9e0d66d2cd1a164898c01 /lib/private/Route
parent56402460121080cb0d63e4c4d4ec51e5b409fed2 (diff)
downloadnextcloud-server-d0b20534b94d0295472ab22157a2bc4c2c9fb703.tar.gz
nextcloud-server-d0b20534b94d0295472ab22157a2bc4c2c9fb703.zip
Refactor "substr" calls to improve code readability
Signed-off-by: Hamid Dehnavi <hamid.dev.pro@gmail.com>
Diffstat (limited to 'lib/private/Route')
-rw-r--r--lib/private/Route/Router.php10
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/private/Route/Router.php b/lib/private/Route/Router.php
index fe97623176d..5ce6c7c5c8f 100644
--- a/lib/private/Route/Router.php
+++ b/lib/private/Route/Router.php
@@ -247,23 +247,23 @@ class Router implements IRouter {
*/
public function findMatchingRoute(string $url): array {
$this->eventLogger->start('route:match', 'Match route');
- if (substr($url, 0, 6) === '/apps/') {
+ if (str_starts_with($url, '/apps/')) {
// empty string / 'apps' / $app / rest of the route
[, , $app,] = explode('/', $url, 4);
$app = \OC_App::cleanAppId($app);
\OC::$REQUESTEDAPP = $app;
$this->loadRoutes($app);
- } elseif (substr($url, 0, 13) === '/ocsapp/apps/') {
+ } elseif (str_starts_with($url, '/ocsapp/apps/')) {
// empty string / 'ocsapp' / 'apps' / $app / rest of the route
[, , , $app,] = explode('/', $url, 5);
$app = \OC_App::cleanAppId($app);
\OC::$REQUESTEDAPP = $app;
$this->loadRoutes($app);
- } elseif (substr($url, 0, 10) === '/settings/') {
+ } elseif (str_starts_with($url, '/settings/')) {
$this->loadRoutes('settings');
- } elseif (substr($url, 0, 6) === '/core/') {
+ } elseif (str_starts_with($url, '/core/')) {
\OC::$REQUESTEDAPP = $url;
if (!$this->config->getSystemValueBool('maintenance') && !Util::needUpgrade()) {
\OC_App::loadApps();
@@ -277,7 +277,7 @@ class Router implements IRouter {
try {
$parameters = $matcher->match($url);
} catch (ResourceNotFoundException $e) {
- if (substr($url, -1) !== '/') {
+ if (!str_ends_with($url, '/')) {
// We allow links to apps/files? for backwards compatibility reasons
// However, since Symfony does not allow empty route names, the route
// we need to match is '/', so we need to append the '/' here.