| Conditions | 4 |
| Paths | 8 |
| Total Lines | 53 |
| Code Lines | 35 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| 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 |
||
| 24 | public static function getSubscribingMethods() |
||
| 25 | { |
||
| 26 | $methods = []; |
||
| 27 | |||
| 28 | foreach (self::SUPPORTED_FORMATS as $format) { |
||
| 29 | $methods[] = [ |
||
| 30 | 'direction' => GraphNavigatorInterface::DIRECTION_SERIALIZATION, |
||
| 31 | 'type' => Iterator::class, |
||
| 32 | 'format' => $format, |
||
| 33 | 'method' => 'serializeIterable', |
||
| 34 | ]; |
||
| 35 | |||
| 36 | $methods[] = [ |
||
| 37 | 'direction' => GraphNavigatorInterface::DIRECTION_DESERIALIZATION, |
||
| 38 | 'type' => Iterator::class, |
||
| 39 | 'format' => $format, |
||
| 40 | 'method' => 'deserializeIterator', |
||
| 41 | ]; |
||
| 42 | } |
||
| 43 | |||
| 44 | foreach (self::SUPPORTED_FORMATS as $format) { |
||
| 45 | $methods[] = [ |
||
| 46 | 'direction' => GraphNavigatorInterface::DIRECTION_SERIALIZATION, |
||
| 47 | 'type' => ArrayIterator::class, |
||
| 48 | 'format' => $format, |
||
| 49 | 'method' => 'serializeIterable', |
||
| 50 | ]; |
||
| 51 | |||
| 52 | $methods[] = [ |
||
| 53 | 'direction' => GraphNavigatorInterface::DIRECTION_DESERIALIZATION, |
||
| 54 | 'type' => ArrayIterator::class, |
||
| 55 | 'format' => $format, |
||
| 56 | 'method' => 'deserializeIterator', |
||
| 57 | ]; |
||
| 58 | } |
||
| 59 | |||
| 60 | foreach (self::SUPPORTED_FORMATS as $format) { |
||
| 61 | $methods[] = [ |
||
| 62 | 'direction' => GraphNavigatorInterface::DIRECTION_SERIALIZATION, |
||
| 63 | 'type' => Generator::class, |
||
| 64 | 'format' => $format, |
||
| 65 | 'method' => 'serializeIterable', |
||
| 66 | ]; |
||
| 67 | |||
| 68 | $methods[] = [ |
||
| 69 | 'direction' => GraphNavigatorInterface::DIRECTION_DESERIALIZATION, |
||
| 70 | 'type' => Generator::class, |
||
| 71 | 'format' => $format, |
||
| 72 | 'method' => 'deserializeGenerator', |
||
| 73 | ]; |
||
| 74 | } |
||
| 75 | |||
| 76 | return $methods; |
||
| 77 | } |
||
| 126 |