RequestHelper   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 14
rs 10
c 0
b 0
f 0
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A getPathInfo() 0 12 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Tebe\Pvc\Helper;
6
7
use Psr\Http\Message\ServerRequestInterface;
8
9
class RequestHelper
10
{
11
    public static function getPathInfo(ServerRequestInterface $request): string
12
    {
13
        $serverParams = $request->getServerParams();
14
        $pathInfo = $serverParams['PATH_INFO'] ?? '';
15
        $pathInfo = trim($pathInfo, '/');
16
        if (empty($pathInfo)) {
17
            $pathInfo = 'index/index';
18
        }
19
        if (strpos($pathInfo, '/') === false) {
20
            $pathInfo .= '/index';
21
        }
22
        return $pathInfo;
23
    }
24
}
25