Completed
Push — master ( 0a87ab...6b6722 )
by Restu
13:56
created

Request::method()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
namespace JayaCode\Framework\Core\Http;
3
4
class Request extends \Symfony\Component\HttpFoundation\Request
5
{
6
7
    /**
8
     * Get the current path info for the request.
9
     *
10
     * @return string
11
     */
12
    public function path()
13
    {
14
        $pattern = trim($this->getPathInfo(), '/');
15
        return $pattern == '' ? '/' : $pattern;
16
    }
17
    
18
    /**
19
     * Get the request method.
20
     *
21
     * @return string
22
     */
23
    public function method()
24
    {
25
        return $this->getMethod();
26
    }
27
28
    /**
29
     * Get the root URL
30
     *
31
     * @return string
32
     */
33
    public function rootURL()
34
    {
35
        return rtrim($this->getSchemeAndHttpHost().$this->getBaseUrl(), '/');
36
    }
37
38
    /**
39
     * Return true if server HTTP_REFERER isset
40
     *
41
     * @return bool
42
     */
43
    public function hasRefererURL()
44
    {
45
        return $this->server->has("HTTP_REFERER");
46
    }
47
48
    /**
49
     * Return server HTTP_REFERER
50
     *
51
     * @return string
52
     */
53
    public function refererURL()
54
    {
55
        return $this->server->get("HTTP_REFERER");
56
    }
57
58
    /**
59
     * Return IP address client
60
     *
61
     * @return string
62
     */
63
    public function ip()
64
    {
65
        return $this->getClientIp();
66
    }
67
68
    /**
69
     * Return IP address client
70
     *
71
     * @return array
72
     */
73
    public function ipAll()
74
    {
75
        return $this->getClientIps();
76
    }
77
}
78