Conditions | 10 |
Paths | 128 |
Total Lines | 34 |
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 |
||
54 | public function search(SearchRaListingCommand $command) |
||
55 | { |
||
56 | $query = new RaListingSearchQuery($command->actorId, $command->pageNumber); |
||
57 | |||
58 | if ($command->name) { |
||
59 | $query->setName($command->name); |
||
60 | } |
||
61 | |||
62 | if ($command->email) { |
||
63 | $query->setEmail($command->email); |
||
64 | } |
||
65 | |||
66 | if ($command->institution) { |
||
67 | $query->setInstitution($command->institution); |
||
68 | } |
||
69 | |||
70 | if ($command->roleAtInstitution && $command->roleAtInstitution->hasRole()) { |
||
71 | $query->setRole($command->roleAtInstitution->getRole()); |
||
72 | } |
||
73 | |||
74 | if ($command->roleAtInstitution && $command->roleAtInstitution->hasInstitution()) { |
||
75 | $query->setRaInstitution($command->roleAtInstitution->getInstitution()); |
||
76 | } |
||
77 | |||
78 | if ($command->orderBy) { |
||
79 | $query->setOrderBy($command->orderBy); |
||
80 | } |
||
81 | |||
82 | if ($command->orderDirection) { |
||
83 | $query->setOrderDirection($command->orderDirection); |
||
84 | } |
||
85 | |||
86 | return $this->apiRaListingService->search($query); |
||
87 | } |
||
88 | |||
112 |