| Conditions | 12 |
| Paths | 12 |
| Total Lines | 54 |
| Code Lines | 32 |
| 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 |
||
| 49 | public function process() |
||
| 50 | { |
||
| 51 | |||
| 52 | $quoteDepth = 1; |
||
| 53 | |||
| 54 | foreach ($this->calls as $call) { |
||
| 55 | switch ($call[0]) { |
||
| 56 | |||
| 57 | /** @noinspection PhpMissingBreakStatementInspection */ |
||
| 58 | case 'quote_start': |
||
| 59 | $this->quoteCalls[] = array('quote_open',array(),$call[2]); |
||
| 60 | // fallthrough |
||
| 61 | case 'quote_newline': |
||
| 62 | $quoteLength = $this->getDepth($call[1][0]); |
||
| 63 | |||
| 64 | if ($quoteLength > $quoteDepth) { |
||
| 65 | $quoteDiff = $quoteLength - $quoteDepth; |
||
| 66 | for ($i = 1; $i <= $quoteDiff; $i++) { |
||
| 67 | $this->quoteCalls[] = array('quote_open',array(),$call[2]); |
||
| 68 | } |
||
| 69 | } elseif ($quoteLength < $quoteDepth) { |
||
| 70 | $quoteDiff = $quoteDepth - $quoteLength; |
||
| 71 | for ($i = 1; $i <= $quoteDiff; $i++) { |
||
| 72 | $this->quoteCalls[] = array('quote_close',array(),$call[2]); |
||
| 73 | } |
||
| 74 | } else { |
||
| 75 | if ($call[0] != 'quote_start') $this->quoteCalls[] = array('linebreak',array(),$call[2]); |
||
| 76 | } |
||
| 77 | |||
| 78 | $quoteDepth = $quoteLength; |
||
| 79 | |||
| 80 | break; |
||
| 81 | |||
| 82 | case 'quote_end': |
||
| 83 | if ($quoteDepth > 1) { |
||
| 84 | $quoteDiff = $quoteDepth - 1; |
||
| 85 | for ($i = 1; $i <= $quoteDiff; $i++) { |
||
| 86 | $this->quoteCalls[] = array('quote_close',array(),$call[2]); |
||
| 87 | } |
||
| 88 | } |
||
| 89 | |||
| 90 | $this->quoteCalls[] = array('quote_close',array(),$call[2]); |
||
| 91 | |||
| 92 | $this->callWriter->writeCalls($this->quoteCalls); |
||
| 93 | break; |
||
| 94 | |||
| 95 | default: |
||
| 96 | $this->quoteCalls[] = $call; |
||
| 97 | break; |
||
| 98 | } |
||
| 99 | } |
||
| 100 | |||
| 101 | return $this->callWriter; |
||
| 102 | } |
||
| 103 | |||
| 111 |