Conditions | 16 |
Paths | 66 |
Total Lines | 69 |
Code Lines | 46 |
Lines | 0 |
Ratio | 0 % |
Changes | 4 | ||
Bugs | 4 | 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 |
||
43 | public function handle() |
||
44 | { |
||
45 | if(isset($this->arguments['filter'])){ |
||
46 | |||
47 | $filterResult = []; |
||
48 | $filter = lcfirst($this->arguments['filter']); |
||
49 | |||
50 | foreach (explode('+',$filter) as $item){ |
||
51 | $itemList = explode('=',$item); |
||
52 | if(isset($this->output[$itemList[0]]) && $this->output[$itemList[0]]==$itemList[1]){ |
||
53 | $filterResult[] = true; |
||
54 | } |
||
55 | else{ |
||
56 | $filterResult[] = false; |
||
57 | } |
||
58 | } |
||
59 | } |
||
60 | |||
61 | if(!isset($filterResult) || (isset($filterResult) && is_array($filterResult) && !in_array(false,$filterResult))){ |
||
62 | |||
63 | if($this->output['meta']['success']) |
||
64 | { |
||
65 | echo ''.$this->output['trackNumber'].' - SUCCESS:'; |
||
66 | echo PHP_EOL; |
||
67 | echo 'Request Success : true'; |
||
68 | } |
||
69 | else{ |
||
70 | |||
71 | echo ''.$this->output['trackNumber'].' - ERROR:'; |
||
72 | echo PHP_EOL; |
||
73 | echo 'Error: '.$this->output['resource']['errorMessage']; |
||
74 | echo PHP_EOL; |
||
75 | echo 'Error File: '.$this->output['resource']['errorFile']; |
||
76 | echo PHP_EOL; |
||
77 | echo 'Error Line: '.$this->output['resource']['errorLine']; |
||
78 | echo PHP_EOL; |
||
79 | echo 'Error Type: '.$this->output['resource']['errorType']; |
||
80 | } |
||
81 | |||
82 | echo PHP_EOL; |
||
83 | echo 'Request Code: '.$this->output['meta']['status']; |
||
84 | |||
85 | echo PHP_EOL; |
||
86 | $requestClientIp = (isset($this->output['clientIp'])) ? $this->output['clientIp'] : null; |
||
87 | echo 'Client Ip: '.$requestClientIp ; |
||
88 | |||
89 | echo PHP_EOL; |
||
90 | $requestEndpoint = (isset($this->output['requestUrl'])) ? $this->output['requestUrl'] : null; |
||
91 | echo 'Endpoint: '.$requestEndpoint; |
||
92 | |||
93 | echo PHP_EOL; |
||
94 | echo 'Get Data: '.json_encode(isset($this->output['getData']) ? $this->output['getData'] : []); |
||
95 | |||
96 | echo PHP_EOL; |
||
97 | echo 'Post Data: '.json_encode(isset($this->output['postData']) ? $this->output['postData'] : []); |
||
98 | |||
99 | echo PHP_EOL; |
||
100 | $requestAuth = (isset($this->output['auth'])) ? $this->output['auth'] : null; |
||
101 | echo 'Auth: '.$requestAuth; |
||
102 | |||
103 | echo PHP_EOL; |
||
104 | echo 'Time: '.date('Y-m-d H:i:s'); |
||
105 | |||
106 | echo PHP_EOL; |
||
107 | $requestClientKey = (isset($this->output['clientApiTokenKey'])) ? $this->output['clientApiTokenKey'] : null; |
||
108 | echo 'Client Key: '.$requestClientKey; |
||
109 | |||
110 | echo PHP_EOL; |
||
111 | echo PHP_EOL; |
||
112 | } |
||
116 | } |