Conditions | 15 |
Paths | 512 |
Total Lines | 124 |
Code Lines | 59 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
130 | public function setErrorHandler($errNo=null, $errStr=null, $errFile=null, $errLine=null, $errContext=null) |
||
131 | { |
||
132 | // in case of a deficiency, |
||
133 | // we need to boot our general needs to be needed for the exception. |
||
134 | Dependencies::loadBootstrapperNeedsForException(); |
||
135 | |||
136 | // in general we will use the exception class |
||
137 | // in the store/config directory to make it possible |
||
138 | // to change the user-based exceptions. |
||
139 | $this->data['exception'] = $this->exception; |
||
140 | $this->data['errType'] = 'Undefined'; |
||
141 | $this->data['errStrReal'] = $errStr; |
||
142 | $this->data['errorClassNamespace'] = null; |
||
143 | $this->data['errFile'] = $errFile; |
||
144 | $this->data['errLine'] = $errLine; |
||
145 | $this->data['errNo'] = $errNo; |
||
146 | |||
147 | // catch exception via preg match |
||
148 | // and then clear the Uncaught statement from inside. |
||
149 | $this->getUncaughtProcess(); |
||
150 | |||
151 | //get status from context |
||
152 | $this->getStatusFromContext(); |
||
153 | |||
154 | //get lang message for exception |
||
155 | $this->getLangMessageForException(); |
||
156 | |||
157 | if($this->app->has('exceptiontrace')){ |
||
158 | |||
159 | $customExceptionTrace = $this->app['exceptiontrace']; |
||
160 | $this->data['errFile'] = $customExceptionTrace['file']; |
||
161 | $this->data['errLine'] = $customExceptionTrace['line']; |
||
162 | } |
||
163 | |||
164 | $environment = $this->app->environment(); |
||
165 | |||
166 | $vendorDirectory = str_replace(root.''.DIRECTORY_SEPARATOR.'','',$this->data['errFile']); |
||
167 | |||
168 | if(preg_match('@vendor.*\.php@is',$vendorDirectory,$vd)){ |
||
169 | $vendorDirectory = $vd[0]; |
||
170 | } |
||
171 | |||
172 | if(Str::startsWith($vendorDirectory,'vendor') |
||
173 | && Str::startsWith($vendorDirectory,'vendor/php-resta')===false) |
||
174 | { |
||
175 | |||
176 | $externalMessage = ($environment==="production") ? |
||
177 | 'An unexpected external error has occurred' : |
||
178 | $this->data['errStrReal']; |
||
179 | |||
180 | $this->result = $this->getAppException($environment,$externalMessage); |
||
181 | |||
182 | |||
183 | //Get or Set the HTTP response code |
||
184 | http_response_code(500); |
||
185 | $this->app->terminate('responseStatus'); |
||
186 | $this->app->register('responseStatus',500); |
||
187 | |||
188 | |||
189 | } |
||
190 | else{ |
||
191 | |||
192 | if($this->data['status']=='500' && $environment=='production'){ |
||
193 | $externalMessage = 'An unexpected external error has occurred'; |
||
194 | } |
||
195 | else{ |
||
196 | $externalMessage = $this->data['errStrReal']; |
||
197 | } |
||
198 | |||
199 | $this->result = $this->getAppException($environment,$externalMessage); |
||
200 | |||
201 | //Get or Set the HTTP response code |
||
202 | http_response_code($this->data['status']); |
||
203 | } |
||
204 | |||
205 | // exception extender The exception information |
||
206 | // that is presented as an extra to the exception result set. |
||
207 | $this->result = $this->getExceptionExtender(); |
||
208 | |||
209 | if($environment==="production"){ |
||
210 | $productionLogMessage = $this->getAppException('local',$this->data['errStrReal']); |
||
211 | $productionLogMessage = array_merge($this->result,$productionLogMessage); |
||
212 | $this->app->register('productionLogMessage',$this->app->get('out')->outputFormatter($productionLogMessage)); |
||
213 | } |
||
214 | |||
215 | //set json app exception |
||
216 | $this->app->register('routerResult',$this->result); |
||
217 | |||
218 | if($this->app->has('exceptionResponse')){ |
||
219 | $exceptionResponse = $this->app->get('exceptionResponse'); |
||
220 | $exceptionResponse((isset($productionLogMessage)) ? $productionLogMessage : $this->result,$this->data['status']); |
||
221 | } |
||
222 | |||
223 | $restaOutHandle = null; |
||
224 | |||
225 | if(!defined('responseApp')){ |
||
226 | $restaOutHandle = $this->app->get('out')->handle(); |
||
227 | } |
||
228 | |||
229 | header("HTTP/1.1 ".$this->data['status']); |
||
230 | |||
231 | if($restaOutHandle===null){ |
||
232 | |||
233 | //header set and symfony response call |
||
234 | $lastResult = $this->app->get('out')->outputFormatter($this->result); |
||
235 | |||
236 | if($this->app->has('clientResponseType')){ |
||
237 | |||
238 | $responseType = $this->app->get('clientResponseType'); |
||
239 | echo app()->resolve($this->app->get('out')->formatter())->{$responseType}($lastResult); |
||
240 | } |
||
241 | else{ |
||
242 | |||
243 | $defaultResponseType = (is_null(config('app.response'))) ? 'json' : config('app.response'); |
||
244 | echo app()->resolve($this->app->get('out')->formatter())->{$defaultResponseType}($lastResult); |
||
245 | } |
||
246 | |||
247 | |||
248 | } |
||
249 | else{ |
||
250 | echo $restaOutHandle; |
||
251 | } |
||
252 | |||
253 | exit(); |
||
254 | } |
||
425 | } |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.