Conditions | 10 |
Paths | 11 |
Total Lines | 38 |
Code Lines | 23 |
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 |
||
59 | public function handle(ServerRequestInterface $request): ResponseInterface |
||
60 | { |
||
61 | $this->layout = 'layouts/ajax'; |
||
62 | |||
63 | if ($this->module === null) { |
||
64 | throw new HttpNotFoundException(I18N::translate('The attached module could not be found.')); |
||
65 | } |
||
66 | $tree = Validator::attributes($request)->tree(); |
||
67 | |||
68 | $adapter_id = Validator::attributes($request)->integer('adapter_id', -1); |
||
69 | $map_adapter = $this->mapadapter_data_service->find($adapter_id); |
||
70 | |||
71 | $mapper_class = Validator::queryParams($request)->string('mapper', ''); |
||
72 | $mapper = null; |
||
73 | if ($mapper_class === '' && $map_adapter !== null) { |
||
74 | $mapper = $map_adapter->placeMapper(); |
||
75 | } else { |
||
76 | try { |
||
77 | $mapper = app($mapper_class); |
||
78 | } catch (BindingResolutionException $ex) { |
||
|
|||
79 | } |
||
80 | |||
81 | if ( |
||
82 | $mapper !== null && $map_adapter !== null && |
||
83 | get_class($map_adapter->placeMapper()) === get_class($mapper) |
||
84 | ) { |
||
85 | $mapper = $map_adapter->placeMapper(); |
||
86 | } |
||
87 | } |
||
88 | |||
89 | if ($mapper === null || !($mapper instanceof PlaceMapperInterface)) { |
||
90 | throw new HttpNotFoundException( |
||
91 | I18N::translate('The configuration for the place mapper could not be found.') |
||
92 | ); |
||
93 | } |
||
94 | |||
95 | return $this->viewResponse('layouts/ajax', [ |
||
96 | 'content' => $mapper->config()->configContent($this->module, $tree) |
||
97 | ]); |
||
100 |