| Total Complexity | 8 |
| Total Lines | 54 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 10 | class Request extends BaseRequest implements RequestInterface |
||
| 11 | { |
||
| 12 | protected $urlParameter; |
||
| 13 | |||
| 14 | /** |
||
| 15 | * 设置路由匹配值 |
||
| 16 | * |
||
| 17 | * @param array $value |
||
| 18 | * @return void |
||
| 19 | */ |
||
| 20 | public function setUrlParameter(array $value) { |
||
| 21 | $this->urlParameter = $value; |
||
| 22 | } |
||
| 23 | |||
| 24 | /** |
||
| 25 | * 获取GET值 |
||
| 26 | * |
||
| 27 | * @param string|null $name |
||
| 28 | * @param mixed $default |
||
| 29 | * @return mixed |
||
| 30 | */ |
||
| 31 | public function getParameter(?string $name = null, $default = null) { |
||
| 32 | if (is_null($name)) { |
||
| 33 | return array_merge($this->queryParameter, $this->urlParameter); |
||
| 34 | } |
||
| 35 | return $this->urlParameter[$name] && $this->queryParameter[$name] ?? $default; |
||
| 36 | } |
||
| 37 | |||
| 38 | /** |
||
| 39 | * 获取查询参数 |
||
| 40 | * |
||
| 41 | * @param string|null $name |
||
| 42 | * @param mixed $default |
||
| 43 | * @return mixed |
||
| 44 | */ |
||
| 45 | public function getQueryParameter(?string $name = null, $default = null) { |
||
| 46 | if (is_null($name)) { |
||
| 47 | return $this->queryParameter; |
||
| 48 | } |
||
| 49 | return $this->queryParameter[$name] ?? $default; |
||
| 50 | } |
||
| 51 | |||
| 52 | /** |
||
| 53 | * 获取URL中的参数 |
||
| 54 | * |
||
| 55 | * @param string|null $name |
||
| 56 | * @param mixed $default |
||
| 57 | * @return mixed |
||
| 58 | */ |
||
| 59 | public function getUrlParameter(?string $name = null, $default = null) { |
||
| 64 | } |
||
| 65 | } |
||
| 66 |