Total Complexity | 9 |
Total Lines | 70 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
17 | trait RequestContextTrait |
||
18 | { |
||
19 | /** |
||
20 | * @var array |
||
21 | */ |
||
22 | private $params; |
||
23 | |||
24 | /** |
||
25 | * @return array |
||
26 | */ |
||
27 | abstract protected function createParams(): array; |
||
28 | |||
29 | /** |
||
30 | * @return array |
||
31 | */ |
||
32 | protected function getParams(): array |
||
33 | { |
||
34 | $this->params or $this->params = $this->createParams(); |
||
35 | return $this->params; |
||
36 | } |
||
37 | |||
38 | /** |
||
39 | * @param array $params |
||
40 | */ |
||
41 | protected function setParams(array $params): void |
||
44 | } |
||
45 | |||
46 | /** |
||
47 | * @param string $offset |
||
48 | * @return bool |
||
49 | */ |
||
50 | public function offsetExists($offset) |
||
51 | { |
||
52 | return array_key_exists((string) $offset, $this->getParams()); |
||
53 | } |
||
54 | |||
55 | /** |
||
56 | * @param string $offset |
||
57 | * @return mixed |
||
58 | */ |
||
59 | public function offsetGet($offset) |
||
60 | { |
||
61 | return $this->offsetExists($offset) ? $this->getParams()[(string) $offset] : null; |
||
62 | } |
||
63 | |||
64 | /** |
||
65 | * @param string $offset |
||
66 | * @param mixed $value |
||
67 | */ |
||
68 | public function offsetSet($offset, $value) |
||
69 | { |
||
70 | // read-only |
||
71 | } |
||
72 | |||
73 | /** |
||
74 | * @param string $offset |
||
75 | */ |
||
76 | public function offsetUnset($offset) |
||
77 | { |
||
78 | // read-only |
||
79 | } |
||
80 | |||
81 | /** |
||
82 | * @return array |
||
83 | */ |
||
84 | public function toArray(): array |
||
87 | } |
||
88 | } |
||
89 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.