1 | <?php |
||
21 | class Agent implements AgentContract |
||
22 | { |
||
23 | /* ----------------------------------------------------------------- |
||
24 | | Properties |
||
25 | | ----------------------------------------------------------------- |
||
26 | */ |
||
27 | |||
28 | /** |
||
29 | * @var \Illuminate\Contracts\Foundation\Application |
||
30 | */ |
||
31 | protected $app; |
||
32 | |||
33 | /** |
||
34 | * @var \Illuminate\Http\Request |
||
35 | */ |
||
36 | protected $request; |
||
37 | |||
38 | /** |
||
39 | * Parsed request. |
||
40 | * |
||
41 | * @var array |
||
42 | */ |
||
43 | protected $parsed; |
||
44 | |||
45 | /* ----------------------------------------------------------------- |
||
46 | | Constructor |
||
47 | | ----------------------------------------------------------------- |
||
48 | */ |
||
49 | |||
50 | /** |
||
51 | * Agent constructor. |
||
52 | * |
||
53 | * @param \Illuminate\Contracts\Foundation\Application $app |
||
54 | */ |
||
55 | 384 | public function __construct(Application $app) |
|
59 | |||
60 | /* ----------------------------------------------------------------- |
||
61 | | Getters & Setters |
||
62 | | ----------------------------------------------------------------- |
||
63 | */ |
||
64 | |||
65 | /** |
||
66 | * Set the request instance. |
||
67 | * |
||
68 | * @param \Illuminate\Http\Request $request |
||
69 | * |
||
70 | * @return $this |
||
71 | */ |
||
72 | 372 | public function setRequest(Request $request) |
|
78 | |||
79 | /** |
||
80 | * Get the request instance. |
||
81 | * |
||
82 | * @return \Illuminate\Http\Request |
||
83 | */ |
||
84 | 372 | public function getRequest(): Request |
|
88 | |||
89 | /** |
||
90 | * Get the detectors. |
||
91 | * |
||
92 | * @return array |
||
93 | */ |
||
94 | 378 | protected function detectors(): array |
|
98 | |||
99 | /** |
||
100 | * Get the supported detectors |
||
101 | * |
||
102 | * @return array |
||
103 | */ |
||
104 | 372 | protected function supportedDetectors(): array |
|
108 | |||
109 | /** |
||
110 | * @param string $key |
||
111 | * |
||
112 | * @return \Arcanedev\Agent\Contracts\Detector|mixed |
||
113 | */ |
||
114 | 372 | protected function getParsed(string $key): Detector |
|
118 | |||
119 | /* ----------------------------------------------------------------- |
||
120 | | Main Methods |
||
121 | | ----------------------------------------------------------------- |
||
122 | */ |
||
123 | |||
124 | /** |
||
125 | * Parse the given request. |
||
126 | * |
||
127 | * @param \Illuminate\Http\Request|null $request |
||
128 | * |
||
129 | * @return $this |
||
130 | */ |
||
131 | 372 | public function parse(Request $request = null): AgentContract |
|
143 | |||
144 | /** |
||
145 | * Make a detector. |
||
146 | * |
||
147 | * @param string $key |
||
148 | * |
||
149 | * @return \Arcanedev\Agent\Contracts\Detector |
||
150 | */ |
||
151 | 372 | public function detector(string $key): Detector |
|
157 | |||
158 | /* ----------------------------------------------------------------- |
||
159 | | Check Methods |
||
160 | | ----------------------------------------------------------------- |
||
161 | */ |
||
162 | |||
163 | /** |
||
164 | * Check if the detector exists. |
||
165 | * |
||
166 | * @param string $name |
||
167 | * |
||
168 | * @return bool |
||
169 | */ |
||
170 | 378 | protected function hasDetector(string $name): bool |
|
174 | |||
175 | /* ----------------------------------------------------------------- |
||
176 | | Other Methods |
||
177 | | ----------------------------------------------------------------- |
||
178 | */ |
||
179 | |||
180 | /** |
||
181 | * @param string $name |
||
182 | * @param array $params |
||
183 | * |
||
184 | * @return \Arcanedev\Agent\Contracts\Detector |
||
185 | */ |
||
186 | 378 | public function __call($name, $params) |
|
194 | } |
||
195 |