1 | <?php |
||
15 | class Recorder extends Component { |
||
16 | |||
17 | /** |
||
18 | * @var mixed |
||
19 | */ |
||
20 | protected $config = []; |
||
21 | |||
22 | /** |
||
23 | * @var array |
||
24 | */ |
||
25 | protected $absolutelyDontHandle = [ |
||
26 | \Tylercd100\LERN\Exceptions\RecorderFailedException::class, |
||
27 | \Doctrine\DBAL\Driver\PDOException::class, |
||
28 | ]; |
||
29 | |||
30 | /** |
||
31 | * The constructor |
||
32 | */ |
||
33 | 36 | public function __construct() { |
|
36 | |||
37 | /** |
||
38 | * Records an Exception to the database |
||
39 | * @param Exception $e The exception you want to record |
||
40 | * @return false|ExceptionModel |
||
41 | * @throws RecorderFailedException |
||
42 | */ |
||
43 | 6 | public function record(Exception $e) |
|
83 | |||
84 | /** |
||
85 | * Checks the config to see if you can collect certain information |
||
86 | * @param string $type the config value you want to check |
||
87 | * @return boolean |
||
88 | */ |
||
89 | 6 | private function canCollect($type) { |
|
95 | |||
96 | /** |
||
97 | * @param string $key |
||
98 | * @param Exception $e |
||
99 | * @return array|int|null|string |
||
100 | * @throws Exception |
||
101 | */ |
||
102 | 6 | protected function collect($key, Exception $e = null) { |
|
123 | |||
124 | /** |
||
125 | * Gets the ID of the User that is logged in |
||
126 | * @return integer|null The ID of the User or Null if not logged in |
||
127 | */ |
||
128 | 6 | protected function getUserId() { |
|
136 | |||
137 | /** |
||
138 | * Gets the Method of the Request |
||
139 | * @return string|null Possible values are null or GET, POST, DELETE, PUT, etc... |
||
140 | */ |
||
141 | 6 | protected function getMethod() { |
|
149 | |||
150 | /** |
||
151 | * Gets the input data of the Request |
||
152 | * @return array|null The Input data or null |
||
153 | */ |
||
154 | 6 | protected function getData() { |
|
162 | |||
163 | /** |
||
164 | * Gets the URL of the Request |
||
165 | * @return string|null Returns a URL string or null |
||
166 | */ |
||
167 | 6 | protected function getUrl() { |
|
175 | |||
176 | /** |
||
177 | * Returns the IP from the request |
||
178 | * |
||
179 | * @return string |
||
180 | */ |
||
181 | protected function getIp() { |
||
184 | |||
185 | /** |
||
186 | * Gets the status code of the Exception |
||
187 | * @param Exception $e The Exception to check |
||
188 | * @return string|integer The status code value |
||
189 | */ |
||
190 | 6 | protected function getStatusCode(Exception $e) { |
|
197 | |||
198 | /** |
||
199 | * This function will remove all keys from an array recursively as defined in the config file |
||
200 | * @param array $data The array to remove keys from |
||
201 | * @return void |
||
202 | */ |
||
203 | 6 | protected function excludeKeys(array $data) { |
|
215 | } |
||
216 |
If you access a property on an interface, you most likely code against a concrete implementation of the interface.
Available Fixes
Adding an additional type check:
Changing the type hint: