Passed
Push — master ( 726597...c9979c )
by mahdi
02:14
created

Request::__callStatic()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 3
rs 10
1
<?php
2
3
namespace Shetabit\Multipay;
4
5
class Request
6
{
7
    /**
8
     * HTTP request's data.
9
     *
10
     * @var array
11
     */
12
    protected $requestData = [];
13
14
    /**
15
     * HTTP POST data.
16
     *
17
     * @var array
18
     */
19
    protected $postData = [];
20
21
    /**
22
     * HTTP GET data.
23
     *
24
     * @var array
25
     */
26
    protected $getData = [];
27
28
    /**
29
     * Request constructor.
30
     */
31
    public function __construct()
32
    {
33
        $this->request = $_REQUEST;
0 ignored issues
show
Bug Best Practice introduced by
The property request does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
34
        $this->post = $_POST;
0 ignored issues
show
Bug Best Practice introduced by
The property post does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
35
        $this->get = $_GET;
0 ignored issues
show
Bug Best Practice introduced by
The property get does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
36
    }
37
38
    /**
39
     * Retrieve HTTP request data.
40
     *
41
     * @param string $name
42
     *
43
     * @return mixed|null
44
     */
45
    public static function input(string $name)
46
    {
47
        return (new static)->requestData[$name] ?? null;
48
    }
49
50
    /**
51
     * Retrieve HTTP POST data.
52
     *
53
     * @param string $name
54
     *
55
     * @return void
56
     */
57
    public static function post(string $name)
58
    {
59
        return (new static)->postData[$name] ?? null;
60
    }
61
62
    /**
63
     * Retrieve HTTP GET data.
64
     *
65
     * @param string $name
66
     *
67
     * @return void
68
     */
69
    public static function get(string $name)
70
    {
71
        return (new static)->getData[$name] ?? null;
72
    }
73
}
74