Conditions | 18 |
Paths | 130 |
Total Lines | 77 |
Code Lines | 51 |
Lines | 0 |
Ratio | 0 % |
Changes | 6 | ||
Bugs | 6 | 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['resource']['errorDetails']['client']['GET']) ? $this->output['resource']['errorDetails']['client']['GET'] : []); |
||
113 | |||
114 | echo PHP_EOL; |
||
115 | echo 'Post Data: '.json_encode(isset($this->output['resource']['errorDetails']['client']['POST']) ? $this->output['resource']['errorDetails']['client']['POST'] : []); |
||
116 | |||
117 | echo PHP_EOL; |
||
118 | echo 'Put Data: '.json_encode(isset($this->output['resource']['errorDetails']['client']['PUT']) ? $this->output['resource']['errorDetails']['client']['PUT'] : []); |
||
119 | |||
120 | echo PHP_EOL; |
||
121 | $requestAuth = (isset($this->output['auth'])) ? $this->output['auth'] : null; |
||
122 | echo 'Auth: '.$requestAuth; |
||
123 | |||
124 | echo PHP_EOL; |
||
125 | echo 'Time: '.date('Y-m-d H:i:s'); |
||
126 | |||
127 | echo PHP_EOL; |
||
128 | $requestClientKey = (isset($this->output['clientApiTokenKey'])) ? $this->output['clientApiTokenKey'] : null; |
||
129 | echo 'Client Key: '.$requestClientKey; |
||
130 | |||
131 | echo PHP_EOL; |
||
132 | if(is_callable($callback)){ |
||
133 | echo $callback($this); |
||
134 | } |
||
135 | |||
136 | echo PHP_EOL; |
||
137 | echo PHP_EOL; |
||
138 | } |
||
140 | } |