| Conditions | 12 |
| Paths | 13 |
| Total Lines | 31 |
| Code Lines | 17 |
| 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 |
||
| 86 | public function pretty_dates() { |
||
| 87 | |||
| 88 | if ($this->to_date == '9999-12-31') { |
||
| 89 | return 'since ' . format_date($this->from_date, SHORTDATEFORMAT); |
||
| 90 | } |
||
| 91 | |||
| 92 | $output = ''; |
||
| 93 | |||
| 94 | if ( |
||
| 95 | !($this->source == 'chgpages/selctee' && $this->from_date == '2004-05-28') and |
||
| 96 | !($this->source == 'chgpages/privsec' && $this->from_date == '2004-05-13') |
||
| 97 | ) { |
||
| 98 | if ($this->source == 'chgpages/privsec' && $this->from_date == '2005-11-10') { |
||
| 99 | $output .= 'before '; |
||
| 100 | } |
||
| 101 | $output .= format_date($this->from_date, SHORTDATEFORMAT) . ' '; |
||
| 102 | } |
||
| 103 | |||
| 104 | $output .= 'to '; |
||
| 105 | |||
| 106 | if ($this->source == 'chgpages/privsec' && $this->to_date == '2005-11-10') { |
||
| 107 | $output .= 'before '; |
||
| 108 | } |
||
| 109 | |||
| 110 | if ($this->source == 'chgpages/privsec' && $this->to_date == '2009-01-16') { |
||
| 111 | $output .= '<a href="/help/#pps_unknown">unknown</a>'; |
||
| 112 | } else { |
||
| 113 | $output .= format_date($this->to_date, SHORTDATEFORMAT); |
||
| 114 | } |
||
| 115 | |||
| 116 | return $output; |
||
| 117 | |||
| 121 |