Total Complexity | 13 |
Total Lines | 81 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 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 | * @param array $options |
||
20 | */ |
||
21 | public function __construct(FoundationRequest $request = null) |
||
22 | { |
||
23 | $this->request = $request ?? FoundationRequest::createFromGlobals(); |
||
24 | |||
25 | $this->keysToFilter = [ |
||
26 | 'password', |
||
27 | 'password_confirmation', |
||
28 | ]; |
||
29 | } |
||
30 | |||
31 | /** |
||
32 | * @return string |
||
33 | */ |
||
34 | public function url(): string |
||
35 | { |
||
36 | return $this->httpRequest() |
||
37 | ? $this->request->getUri() |
||
38 | : ''; |
||
39 | } |
||
40 | |||
41 | /** |
||
42 | * @return array |
||
43 | */ |
||
44 | public function params(): array |
||
54 | ]; |
||
55 | } |
||
56 | |||
57 | /** |
||
58 | * @return array |
||
59 | */ |
||
60 | public function session(): array |
||
61 | { |
||
62 | return $this->request->hasSession() && $this->request->getSession() |
||
63 | ? $this->filter($this->request->getSession()->all()) |
||
64 | : []; |
||
65 | } |
||
66 | |||
67 | /** |
||
68 | * @return bool |
||
69 | */ |
||
70 | private function httpRequest(): bool |
||
71 | { |
||
72 | return isset($_SERVER['REQUEST_METHOD']); |
||
73 | } |
||
74 | |||
75 | /** |
||
76 | * @return array |
||
77 | */ |
||
78 | private function data(): array |
||
89 | } |
||
90 | } |
||
91 |