Conditions | 5 |
Paths | 30 |
Total Lines | 56 |
Code Lines | 40 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | 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 run(Lib_Utils_FileLogger $metaInfoLogger) |
||
44 | { |
||
45 | try { |
||
46 | ob_start(); |
||
47 | $start_time = microtime(TRUE); |
||
48 | |||
49 | try { |
||
50 | $this->_run(); |
||
51 | } catch (SoapFault $fault) { |
||
52 | $end_time = microtime(TRUE); |
||
53 | // some time SoapFaul is sign of positive test result |
||
54 | $resultStr = ob_get_clean(); |
||
55 | $this->_logger->write($resultStr); |
||
56 | print '<pre>' . $resultStr . '</pre>'; |
||
57 | |||
58 | $this->_logger->write($fault->faultstring); |
||
59 | print '<pre>SoapFault:</pre>'; |
||
60 | print '<pre>' . $fault->faultstring . '</pre>'; |
||
61 | |||
62 | try { |
||
63 | // $this->_validateSoapFault($resultStr . $fault->faultstring); |
||
64 | $this->_validateSoapFault($fault->faultstring); |
||
65 | $metaInfoLogger->write(basename($this->getLogName()) . ' - test is ok!'); |
||
66 | } catch (Lib_Exception_InvalidResponse $e) { |
||
67 | $metaInfoLogger->write(basename($this->getLogName()) . ' - test failed!'); |
||
68 | } |
||
69 | |||
70 | return; |
||
71 | } |
||
72 | |||
73 | $end_time = microtime(TRUE); |
||
74 | $resultStr = ob_get_clean(); |
||
75 | $this->_logger->write($resultStr); |
||
76 | print $resultStr; |
||
77 | |||
78 | try { |
||
79 | $this->_validate($resultStr); |
||
80 | $metaInfoLogger->write(basename($this->getLogName()) . ' - test is ok!'); |
||
81 | } catch (Lib_Exception_InvalidResponse $e) { |
||
82 | $metaInfoLogger->write(basename($this->getLogName()) . ' - test failed!'); |
||
83 | } |
||
84 | |||
85 | $metaInfoLogger->write('Total time: '. ($end_time - $start_time)); |
||
86 | $metaInfoLogger->write('Max allocated memory: '. memory_get_peak_usage(TRUE)); |
||
87 | } catch (Exception $e) { |
||
88 | $this->_logger->write($this->_mySforceConnection->getLastRequest()); |
||
89 | ob_start(); |
||
90 | print_r($e); |
||
91 | $eStr = ob_get_clean(); |
||
92 | $this->_logger->write($eStr); |
||
93 | |||
94 | print $this->_mySforceConnection->getLastRequest(); |
||
95 | echo "\n\n\n"; |
||
96 | print $eStr; |
||
97 | |||
98 | $metaInfoLogger->write('Test failed!'); |
||
99 | } |
||
158 |