| Conditions | 10 |
| Paths | 3 |
| Total Lines | 16 |
| 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 |
||
| 32 | public function getEvents(\DateTime $begin, \DateTime $end, array $options = array()) |
||
| 33 | { |
||
| 34 | $events = array(); |
||
| 35 | foreach ($this->events as $event) { |
||
| 36 | if ( |
||
| 37 | ($event->getBegin() >= $begin && $event->getBegin() < $end) || |
||
| 38 | ($event->getEnd() > $begin && $event->getEnd() <= $end) || |
||
| 39 | ($begin <= $event->getBegin() && $event->getEnd() <= $end) || |
||
| 40 | ($event->getBegin() <= $begin && $end <= $event->getEnd()) |
||
| 41 | ) { |
||
| 42 | $events[] = $event; |
||
| 43 | } |
||
| 44 | } |
||
| 45 | |||
| 46 | return $events; |
||
| 47 | } |
||
| 48 | |||
| 89 |