| Conditions | 17 |
| Paths | 130 |
| Total Lines | 74 |
| Code Lines | 49 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 5 | ||
| Bugs | 5 | Features | 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 |
||
| 61 | public function handle($callback) |
||
| 62 | { |
||
| 63 | if(isset($this->arguments['filter'])){ |
||
| 64 | |||
| 65 | $filterResult = []; |
||
| 66 | $filter = lcfirst($this->arguments['filter']); |
||
| 67 | |||
| 68 | foreach (explode('+',$filter) as $item){ |
||
| 69 | $itemList = explode('=',$item); |
||
| 70 | if(isset($this->output[$itemList[0]]) && $this->output[$itemList[0]]==$itemList[1]){ |
||
| 71 | $filterResult[] = true; |
||
| 72 | } |
||
| 73 | else{ |
||
| 74 | $filterResult[] = false; |
||
| 75 | } |
||
| 76 | } |
||
| 77 | } |
||
| 78 | |||
| 79 | if(!isset($filterResult) || (isset($filterResult) && is_array($filterResult) && !in_array(false,$filterResult))){ |
||
| 80 | |||
| 81 | if($this->output['meta']['success']) |
||
| 82 | { |
||
| 83 | echo ''.$this->output['trackNumber'].' - SUCCESS:'; |
||
| 84 | echo PHP_EOL; |
||
| 85 | echo 'Request Success : true'; |
||
| 86 | } |
||
| 87 | else{ |
||
| 88 | |||
| 89 | echo ''.$this->output['trackNumber'].' - ERROR:'; |
||
| 90 | echo PHP_EOL; |
||
| 91 | echo 'Error: '.$this->output['resource']['errorMessage']; |
||
| 92 | echo PHP_EOL; |
||
| 93 | echo 'Error File: '.$this->output['resource']['errorFile']; |
||
| 94 | echo PHP_EOL; |
||
| 95 | echo 'Error Line: '.$this->output['resource']['errorLine']; |
||
| 96 | echo PHP_EOL; |
||
| 97 | echo 'Error Type: '.$this->output['resource']['errorType']; |
||
| 98 | } |
||
| 99 | |||
| 100 | echo PHP_EOL; |
||
| 101 | echo 'Request Code: '.$this->output['meta']['status']; |
||
| 102 | |||
| 103 | echo PHP_EOL; |
||
| 104 | $requestClientIp = (isset($this->output['clientIp'])) ? $this->output['clientIp'] : null; |
||
| 105 | echo 'Client Ip: '.$requestClientIp ; |
||
| 106 | |||
| 107 | echo PHP_EOL; |
||
| 108 | $requestEndpoint = (isset($this->output['requestUrl'])) ? $this->output['requestUrl'] : null; |
||
| 109 | echo 'Endpoint: '.$requestEndpoint; |
||
| 110 | |||
| 111 | echo PHP_EOL; |
||
| 112 | echo 'Get Data: '.json_encode(isset($this->output['getData']) ? $this->output['getData'] : []); |
||
| 113 | |||
| 114 | echo PHP_EOL; |
||
| 115 | echo 'Post Data: '.json_encode(isset($this->output['postData']) ? $this->output['postData'] : []); |
||
| 116 | |||
| 117 | echo PHP_EOL; |
||
| 118 | $requestAuth = (isset($this->output['auth'])) ? $this->output['auth'] : null; |
||
| 119 | echo 'Auth: '.$requestAuth; |
||
| 120 | |||
| 121 | echo PHP_EOL; |
||
| 122 | echo 'Time: '.date('Y-m-d H:i:s'); |
||
| 123 | |||
| 124 | echo PHP_EOL; |
||
| 125 | $requestClientKey = (isset($this->output['clientApiTokenKey'])) ? $this->output['clientApiTokenKey'] : null; |
||
| 126 | echo 'Client Key: '.$requestClientKey; |
||
| 127 | |||
| 128 | echo PHP_EOL; |
||
| 129 | if(is_callable($callback)){ |
||
| 130 | echo $callback($this); |
||
| 131 | } |
||
| 132 | |||
| 133 | echo PHP_EOL; |
||
| 134 | echo PHP_EOL; |
||
| 135 | } |
||
| 137 | } |