Issues (92)

src/Request/Traits/InteractsWithUri.php (5 issues)

Labels
Severity
1
<?php
2
3
namespace Nip\Http\Request\Traits;
4
5
/**
6
 * Class InteractsWithUri
7
 * @package Nip\Http\Request\Traits
8
 */
9
trait InteractsWithUri
10
{
11
12
    /**
13
     * Get the root URL for the application.
14
     *
15
     * @return string
16
     */
17
    public function root()
18
    {
19
        return rtrim($this->getSchemeAndHttpHost() . $this->getBaseUrl(), '/');
0 ignored issues
show
It seems like getBaseUrl() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

19
        return rtrim($this->getSchemeAndHttpHost() . $this->/** @scrutinizer ignore-call */ getBaseUrl(), '/');
Loading history...
It seems like getSchemeAndHttpHost() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

19
        return rtrim($this->/** @scrutinizer ignore-call */ getSchemeAndHttpHost() . $this->getBaseUrl(), '/');
Loading history...
20
    }
21
22
    /**
23
     * Get the full URL for the request.
24
     *
25
     * @return string
26
     */
27
    public function fullUrl()
28
    {
29
        $query = $this->getQueryString();
0 ignored issues
show
It seems like getQueryString() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

29
        /** @scrutinizer ignore-call */ 
30
        $query = $this->getQueryString();
Loading history...
30
        $question = $this->getBaseUrl() . $this->getPathInfo() == '/' ? '/?' : '?';
0 ignored issues
show
It seems like getPathInfo() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

30
        $question = $this->getBaseUrl() . $this->/** @scrutinizer ignore-call */ getPathInfo() == '/' ? '/?' : '?';
Loading history...
31
        return $query ? $this->url() . $question . $query : $this->url();
32
    }
33
34
    /**
35
     * Get the URL (no query string) for the request.
36
     *
37
     * @return string
38
     */
39
    public function url()
40
    {
41
        return rtrim(preg_replace('/\?.*/', '', $this->getUri()), '/');
0 ignored issues
show
It seems like getUri() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

41
        return rtrim(preg_replace('/\?.*/', '', $this->/** @scrutinizer ignore-call */ getUri()), '/');
Loading history...
42
    }
43
44
    /**
45
     * @return array|mixed|string
46
     */
47 9
    protected function prepareRequestUri()
48
    {
49 9
        if ((int) $this->server->get('REDIRECT_STATUS', '200') >= 400 && $this->server->has('REDIRECT_URL')) {
50
            $requestUri = $this->server->get('REDIRECT_URL');
51
            $schemeAndHttpHost = $this->getSchemeAndHttpHost();
52
            if (strpos($requestUri, $schemeAndHttpHost) === 0) {
53
                $requestUri = substr($requestUri, strlen($schemeAndHttpHost));
54
            }
55
            $this->server->set('REQUEST_URI', $requestUri);
56
            return $requestUri;
57
        }
58
59 9
        return parent::prepareRequestUri();
60
    }
61
}
62