Total Complexity | 13 |
Total Lines | 80 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
8 | class Request |
||
9 | { |
||
10 | use FiltersData; |
||
11 | |||
12 | /** |
||
13 | * @var \Symfony\Component\HttpFoundation\Request |
||
14 | */ |
||
15 | protected $request; |
||
16 | |||
17 | /** |
||
18 | * @param \Symfony\Component\HttpFoundation\Request $request |
||
19 | */ |
||
20 | public function __construct(FoundationRequest $request = null) |
||
21 | { |
||
22 | $this->request = $request ?? FoundationRequest::createFromGlobals(); |
||
23 | |||
24 | $this->keysToFilter = [ |
||
25 | 'password', |
||
26 | 'password_confirmation', |
||
27 | ]; |
||
28 | } |
||
29 | |||
30 | /** |
||
31 | * @return string |
||
32 | */ |
||
33 | public function url() : string |
||
34 | { |
||
35 | return $this->httpRequest() |
||
36 | ? $this->request->getUri() |
||
37 | : ''; |
||
38 | } |
||
39 | |||
40 | /** |
||
41 | * @return array |
||
42 | */ |
||
43 | public function params() : array |
||
53 | ]; |
||
54 | } |
||
55 | |||
56 | /** |
||
57 | * @return array |
||
58 | */ |
||
59 | public function session() : array |
||
60 | { |
||
61 | return $this->request->hasSession() && $this->request->getSession() |
||
62 | ? $this->filter($this->request->getSession()->all()) |
||
63 | : []; |
||
64 | } |
||
65 | |||
66 | /** |
||
67 | * @return bool |
||
68 | */ |
||
69 | private function httpRequest() : bool |
||
70 | { |
||
71 | return isset($_SERVER['REQUEST_METHOD']); |
||
72 | } |
||
73 | |||
74 | /** |
||
75 | * @return array |
||
76 | */ |
||
77 | private function data() : array |
||
88 | } |
||
89 | } |
||
90 |