| Conditions | 2 |
| Paths | 2 |
| Total Lines | 57 |
| Code Lines | 39 |
| 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 |
||
| 60 | protected function visitURLAliasAttributes(Visitor $visitor, Generator $generator, URLAliasValue $data) |
||
|
|
|||
| 61 | { |
||
| 62 | $generator->startAttribute( |
||
| 63 | 'href', |
||
| 64 | $this->router->generate('ezpublish_rest_loadURLAlias', array('urlAliasId' => $data->id)) |
||
| 65 | ); |
||
| 66 | $generator->endAttribute('href'); |
||
| 67 | |||
| 68 | $generator->startAttribute('id', $data->id); |
||
| 69 | $generator->endAttribute('id'); |
||
| 70 | |||
| 71 | $generator->startAttribute('type', $this->serializeType($data->type)); |
||
| 72 | $generator->endAttribute('type'); |
||
| 73 | |||
| 74 | if ($data->type === Values\Content\URLAlias::LOCATION) { |
||
| 75 | $generator->startObjectElement('location', 'Location'); |
||
| 76 | $generator->startAttribute( |
||
| 77 | 'href', |
||
| 78 | $this->router->generate('ezpublish_rest_loadLocation', array('locationPath' => $data->destination)) |
||
| 79 | ); |
||
| 80 | $generator->endAttribute('href'); |
||
| 81 | $generator->endObjectElement('location'); |
||
| 82 | } else { |
||
| 83 | $generator->startValueElement('resource', $data->destination); |
||
| 84 | $generator->endValueElement('resource'); |
||
| 85 | } |
||
| 86 | |||
| 87 | $generator->startValueElement('path', $data->path); |
||
| 88 | $generator->endValueElement('path'); |
||
| 89 | |||
| 90 | $generator->startValueElement('languageCodes', implode(',', $data->languageCodes)); |
||
| 91 | $generator->endValueElement('languageCodes'); |
||
| 92 | |||
| 93 | $generator->startValueElement( |
||
| 94 | 'alwaysAvailable', |
||
| 95 | $this->serializeBool($generator, $data->alwaysAvailable) |
||
| 96 | ); |
||
| 97 | $generator->endValueElement('alwaysAvailable'); |
||
| 98 | |||
| 99 | $generator->startValueElement( |
||
| 100 | 'isHistory', |
||
| 101 | $this->serializeBool($generator, $data->isHistory) |
||
| 102 | ); |
||
| 103 | $generator->endValueElement('isHistory'); |
||
| 104 | |||
| 105 | $generator->startValueElement( |
||
| 106 | 'forward', |
||
| 107 | $this->serializeBool($generator, $data->forward) |
||
| 108 | ); |
||
| 109 | $generator->endValueElement('forward'); |
||
| 110 | |||
| 111 | $generator->startValueElement( |
||
| 112 | 'custom', |
||
| 113 | $this->serializeBool($generator, $data->isCustom) |
||
| 114 | ); |
||
| 115 | $generator->endValueElement('custom'); |
||
| 116 | } |
||
| 117 | } |
||
| 118 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.