| Conditions | 5 | 
| Paths | 5 | 
| Total Lines | 59 | 
| Code Lines | 39 | 
| 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  | 
            ||
| 60 | public function handle(ServerRequestInterface $request): ResponseInterface  | 
            ||
| 61 |     { | 
            ||
| 62 | $this->layout = 'layouts/administration';  | 
            ||
| 63 | |||
| 64 |         $place_id = (int) $request->getAttribute('place_id'); | 
            ||
| 65 | $location = $this->map_data_service->findById($place_id);  | 
            ||
| 66 | |||
| 67 |         if ($location->id() === null) { | 
            ||
| 68 | return redirect(route(MapDataList::class));  | 
            ||
| 69 | }  | 
            ||
| 70 | |||
| 71 |         $title = e($location->locationName()) . ' — ' . I18N::translate('Edit'); | 
            ||
| 72 | |||
| 73 | // Build the breadcrumbs in reverse order  | 
            ||
| 74 |         $breadcrumbs = [I18N::translate('Edit')]; | 
            ||
| 75 | |||
| 76 | $tmp = $location;  | 
            ||
| 77 |         while ($tmp->id() !== null) { | 
            ||
| 78 | $breadcrumbs[route(MapDataList::class, ['parent_id' => $tmp->id()])] = e($tmp->locationName());  | 
            ||
| 79 | |||
| 80 | $tmp = $tmp->parent();  | 
            ||
| 81 | }  | 
            ||
| 82 | |||
| 83 |         $breadcrumbs[route(MapDataList::class)]  = I18N::translate('Geographic data'); | 
            ||
| 84 |         $breadcrumbs[route(ControlPanel::class)] = I18N::translate('Control panel'); | 
            ||
| 85 | |||
| 86 | $latitude = $location->latitude();  | 
            ||
| 87 | $longitude = $location->longitude();  | 
            ||
| 88 | $map_bounds = $location->boundingRectangle();  | 
            ||
| 89 | |||
| 90 | // If the current co-ordinates are unknown, leave the input fields empty,  | 
            ||
| 91 | // and show a marker in the middle of the map.  | 
            ||
| 92 |         if ($latitude === null || $longitude === null) { | 
            ||
| 93 | $latitude = '';  | 
            ||
| 94 | $longitude = '';  | 
            ||
| 95 | |||
| 96 | $marker_position = [  | 
            ||
| 97 | ($map_bounds[0][0] + $map_bounds[1][0]) / 2.0,  | 
            ||
| 98 | ($map_bounds[0][1] + $map_bounds[1][1]) / 2.0,  | 
            ||
| 99 | ];  | 
            ||
| 100 |         } else { | 
            ||
| 101 | $marker_position = [$latitude, $longitude];  | 
            ||
| 102 | }  | 
            ||
| 103 | |||
| 104 |         return $this->viewResponse('admin/location-edit', [ | 
            ||
| 105 | 'breadcrumbs' => array_reverse($breadcrumbs, true),  | 
            ||
| 106 | 'title' => $title,  | 
            ||
| 107 | 'location' => $location,  | 
            ||
| 108 | 'latitude' => $latitude,  | 
            ||
| 109 | 'longitude' => $longitude,  | 
            ||
| 110 | 'map_bounds' => $map_bounds,  | 
            ||
| 111 | 'marker_position' => $marker_position,  | 
            ||
| 112 | 'parent' => $location->parent(),  | 
            ||
| 113 |             'openroute_key'   => Site::getPreference('openroute_key'), | 
            ||
| 114 | 'provider' => [  | 
            ||
| 115 |                 'url'     => 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', | 
            ||
| 116 | 'options' => [  | 
            ||
| 117 | 'attribution' => '<a href="https://www.openstreetmap.org/copyright">© OpenStreetMap</a> contributors',  | 
            ||
| 118 | 'max_zoom' => 19  | 
            ||
| 119 | ]  | 
            ||
| 124 |