Passed
Push — main ( 00c5b4...fe37d7 )
by Jonathan
03:49
created
app/Module/GeoDispersion/Http/RequestHandlers/GeoAnalysisViewAddPage.php 2 patches
Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -32,48 +32,48 @@
 block discarded – undo
32 32
  */
33 33
 class GeoAnalysisViewAddPage implements RequestHandlerInterface
34 34
 {
35
-    use ViewResponseTrait;
35
+	use ViewResponseTrait;
36 36
 
37
-    private ?GeoDispersionModule $module;
38
-    private GeoAnalysisService $geoanalysis_service;
39
-    private GeoAnalysisDataService $geoanalysis_data_service;
37
+	private ?GeoDispersionModule $module;
38
+	private GeoAnalysisService $geoanalysis_service;
39
+	private GeoAnalysisDataService $geoanalysis_data_service;
40 40
 
41
-    /**
42
-     * Constructor for GeoAnalysisViewAddPage Request Handler
43
-     *
44
-     * @param ModuleService $module_service
45
-     * @param GeoAnalysisService $geoanalysis_service
46
-     * @param GeoAnalysisDataService $geoanalysis_data_service
47
-     */
48
-    public function __construct(
49
-        ModuleService $module_service,
50
-        GeoAnalysisService $geoanalysis_service,
51
-        GeoAnalysisDataService $geoanalysis_data_service
52
-    ) {
53
-        $this->module = $module_service->findByInterface(GeoDispersionModule::class)->first();
54
-        $this->geoanalysis_service = $geoanalysis_service;
55
-        $this->geoanalysis_data_service = $geoanalysis_data_service;
56
-    }
41
+	/**
42
+	 * Constructor for GeoAnalysisViewAddPage Request Handler
43
+	 *
44
+	 * @param ModuleService $module_service
45
+	 * @param GeoAnalysisService $geoanalysis_service
46
+	 * @param GeoAnalysisDataService $geoanalysis_data_service
47
+	 */
48
+	public function __construct(
49
+		ModuleService $module_service,
50
+		GeoAnalysisService $geoanalysis_service,
51
+		GeoAnalysisDataService $geoanalysis_data_service
52
+	) {
53
+		$this->module = $module_service->findByInterface(GeoDispersionModule::class)->first();
54
+		$this->geoanalysis_service = $geoanalysis_service;
55
+		$this->geoanalysis_data_service = $geoanalysis_data_service;
56
+	}
57 57
 
58
-    /**
59
-     * {@inheritDoc}
60
-     * @see \Psr\Http\Server\RequestHandlerInterface::handle()
61
-     */
62
-    public function handle(ServerRequestInterface $request): ResponseInterface
63
-    {
64
-        $this->layout = 'layouts/administration';
58
+	/**
59
+	 * {@inheritDoc}
60
+	 * @see \Psr\Http\Server\RequestHandlerInterface::handle()
61
+	 */
62
+	public function handle(ServerRequestInterface $request): ResponseInterface
63
+	{
64
+		$this->layout = 'layouts/administration';
65 65
 
66
-        if ($this->module === null) {
67
-            throw new HttpNotFoundException(I18N::translate('The attached module could not be found.'));
68
-        }
69
-        $tree = Validator::attributes($request)->tree();
66
+		if ($this->module === null) {
67
+			throw new HttpNotFoundException(I18N::translate('The attached module could not be found.'));
68
+		}
69
+		$tree = Validator::attributes($request)->tree();
70 70
 
71
-        return $this->viewResponse($this->module->name() . '::admin/view-add', [
72
-            'module'        =>  $this->module,
73
-            'title'         =>  I18N::translate('Add a geographical dispersion analysis view'),
74
-            'tree'          =>  $tree,
75
-            'geoanalysis_list'  =>  $this->geoanalysis_service->all(),
76
-            'place_example'     =>  $this->geoanalysis_data_service->placeHierarchyExample($tree)
77
-        ]);
78
-    }
71
+		return $this->viewResponse($this->module->name() . '::admin/view-add', [
72
+			'module'        =>  $this->module,
73
+			'title'         =>  I18N::translate('Add a geographical dispersion analysis view'),
74
+			'tree'          =>  $tree,
75
+			'geoanalysis_list'  =>  $this->geoanalysis_service->all(),
76
+			'place_example'     =>  $this->geoanalysis_data_service->placeHierarchyExample($tree)
77
+		]);
78
+	}
79 79
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -68,7 +68,7 @@
 block discarded – undo
68 68
         }
69 69
         $tree = Validator::attributes($request)->tree();
70 70
 
71
-        return $this->viewResponse($this->module->name() . '::admin/view-add', [
71
+        return $this->viewResponse($this->module->name().'::admin/view-add', [
72 72
             'module'        =>  $this->module,
73 73
             'title'         =>  I18N::translate('Add a geographical dispersion analysis view'),
74 74
             'tree'          =>  $tree,
Please login to merge, or discard this patch.
app/Module/GeoDispersion/Http/RequestHandlers/MapAdapterEditPage.php 2 patches
Indentation   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -33,68 +33,68 @@
 block discarded – undo
33 33
  */
34 34
 class MapAdapterEditPage implements RequestHandlerInterface
35 35
 {
36
-    use ViewResponseTrait;
36
+	use ViewResponseTrait;
37 37
 
38
-    private ?GeoDispersionModule $module;
39
-    private MapAdapterDataService $mapadapter_data_service;
40
-    private MapDefinitionsService $map_definition_service;
41
-    private PlaceMapperService $place_mapper_service;
38
+	private ?GeoDispersionModule $module;
39
+	private MapAdapterDataService $mapadapter_data_service;
40
+	private MapDefinitionsService $map_definition_service;
41
+	private PlaceMapperService $place_mapper_service;
42 42
 
43
-    /**
44
-     * Constructor for MapAdapterEditPage Request Handler
45
-     *
46
-     * @param ModuleService $module_service
47
-     * @param MapAdapterDataService $mapadapter_data_service
48
-     * @param MapDefinitionsService $map_definition_service
49
-     * @param PlaceMapperService $place_mapper_service
50
-     */
51
-    public function __construct(
52
-        ModuleService $module_service,
53
-        MapAdapterDataService $mapadapter_data_service,
54
-        MapDefinitionsService $map_definition_service,
55
-        PlaceMapperService $place_mapper_service
56
-    ) {
57
-        $this->module = $module_service->findByInterface(GeoDispersionModule::class)->first();
58
-        $this->mapadapter_data_service = $mapadapter_data_service;
59
-        $this->map_definition_service = $map_definition_service;
60
-        $this->place_mapper_service = $place_mapper_service;
61
-    }
43
+	/**
44
+	 * Constructor for MapAdapterEditPage Request Handler
45
+	 *
46
+	 * @param ModuleService $module_service
47
+	 * @param MapAdapterDataService $mapadapter_data_service
48
+	 * @param MapDefinitionsService $map_definition_service
49
+	 * @param PlaceMapperService $place_mapper_service
50
+	 */
51
+	public function __construct(
52
+		ModuleService $module_service,
53
+		MapAdapterDataService $mapadapter_data_service,
54
+		MapDefinitionsService $map_definition_service,
55
+		PlaceMapperService $place_mapper_service
56
+	) {
57
+		$this->module = $module_service->findByInterface(GeoDispersionModule::class)->first();
58
+		$this->mapadapter_data_service = $mapadapter_data_service;
59
+		$this->map_definition_service = $map_definition_service;
60
+		$this->place_mapper_service = $place_mapper_service;
61
+	}
62 62
 
63
-    /**
64
-     * {@inheritDoc}
65
-     * @see \Psr\Http\Server\RequestHandlerInterface::handle()
66
-     */
67
-    public function handle(ServerRequestInterface $request): ResponseInterface
68
-    {
69
-        $this->layout = 'layouts/administration';
63
+	/**
64
+	 * {@inheritDoc}
65
+	 * @see \Psr\Http\Server\RequestHandlerInterface::handle()
66
+	 */
67
+	public function handle(ServerRequestInterface $request): ResponseInterface
68
+	{
69
+		$this->layout = 'layouts/administration';
70 70
 
71
-        if ($this->module === null) {
72
-            throw new HttpNotFoundException(I18N::translate('The attached module could not be found.'));
73
-        }
71
+		if ($this->module === null) {
72
+			throw new HttpNotFoundException(I18N::translate('The attached module could not be found.'));
73
+		}
74 74
 
75
-        $tree = Validator::attributes($request)->tree();
75
+		$tree = Validator::attributes($request)->tree();
76 76
 
77
-        $adapter_id = Validator::attributes($request)->integer('adapter_id', -1);
78
-        $map_adapter = $this->mapadapter_data_service->find($adapter_id);
77
+		$adapter_id = Validator::attributes($request)->integer('adapter_id', -1);
78
+		$map_adapter = $this->mapadapter_data_service->find($adapter_id);
79 79
 
80
-        if ($map_adapter === null) {
81
-            throw new HttpNotFoundException(
82
-                I18N::translate('The map configuration could not be found.')
83
-            );
84
-        }
80
+		if ($map_adapter === null) {
81
+			throw new HttpNotFoundException(
82
+				I18N::translate('The map configuration could not be found.')
83
+			);
84
+		}
85 85
 
86
-        return $this->viewResponse($this->module->name() . '::admin/map-adapter-edit', [
87
-            'module'            =>  $this->module,
88
-            'title'             =>  I18N::translate('Edit the map configuration'),
89
-            'tree'              =>  $tree,
90
-            'view_id'           =>  $map_adapter->geoAnalysisViewId(),
91
-            'map_adapter'       =>  $map_adapter,
92
-            'maps_list'         =>  $this->map_definition_service->all(),
93
-            'mappers_list'      =>  $this->place_mapper_service->all(),
94
-            'route_edit'        =>  route(MapAdapterEditAction::class, [
95
-                                        'tree' => $tree->name(),
96
-                                        'adapter_id' => $map_adapter->id()
97
-                                    ])
98
-        ]);
99
-    }
86
+		return $this->viewResponse($this->module->name() . '::admin/map-adapter-edit', [
87
+			'module'            =>  $this->module,
88
+			'title'             =>  I18N::translate('Edit the map configuration'),
89
+			'tree'              =>  $tree,
90
+			'view_id'           =>  $map_adapter->geoAnalysisViewId(),
91
+			'map_adapter'       =>  $map_adapter,
92
+			'maps_list'         =>  $this->map_definition_service->all(),
93
+			'mappers_list'      =>  $this->place_mapper_service->all(),
94
+			'route_edit'        =>  route(MapAdapterEditAction::class, [
95
+										'tree' => $tree->name(),
96
+										'adapter_id' => $map_adapter->id()
97
+									])
98
+		]);
99
+	}
100 100
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -83,7 +83,7 @@
 block discarded – undo
83 83
             );
84 84
         }
85 85
 
86
-        return $this->viewResponse($this->module->name() . '::admin/map-adapter-edit', [
86
+        return $this->viewResponse($this->module->name().'::admin/map-adapter-edit', [
87 87
             'module'            =>  $this->module,
88 88
             'title'             =>  I18N::translate('Edit the map configuration'),
89 89
             'tree'              =>  $tree,
Please login to merge, or discard this patch.
app/Module/GeoDispersion/Http/RequestHandlers/MapAdapterMapperConfig.php 1 patch
Indentation   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -33,67 +33,67 @@
 block discarded – undo
33 33
  */
34 34
 class MapAdapterMapperConfig implements RequestHandlerInterface
35 35
 {
36
-    use ViewResponseTrait;
36
+	use ViewResponseTrait;
37 37
 
38
-    private ?GeoDispersionModule $module;
39
-    private MapAdapterDataService $mapadapter_data_service;
38
+	private ?GeoDispersionModule $module;
39
+	private MapAdapterDataService $mapadapter_data_service;
40 40
 
41
-    /**
42
-     * Constructor for MapAdapterMapperConfig Request Handler
43
-     *
44
-     * @param ModuleService $module_service
45
-     * @param MapAdapterDataService $mapadapter_data_service
46
-     */
47
-    public function __construct(
48
-        ModuleService $module_service,
49
-        MapAdapterDataService $mapadapter_data_service
50
-    ) {
51
-        $this->module = $module_service->findByInterface(GeoDispersionModule::class)->first();
52
-        $this->mapadapter_data_service = $mapadapter_data_service;
53
-    }
41
+	/**
42
+	 * Constructor for MapAdapterMapperConfig Request Handler
43
+	 *
44
+	 * @param ModuleService $module_service
45
+	 * @param MapAdapterDataService $mapadapter_data_service
46
+	 */
47
+	public function __construct(
48
+		ModuleService $module_service,
49
+		MapAdapterDataService $mapadapter_data_service
50
+	) {
51
+		$this->module = $module_service->findByInterface(GeoDispersionModule::class)->first();
52
+		$this->mapadapter_data_service = $mapadapter_data_service;
53
+	}
54 54
 
55
-    /**
56
-     * {@inheritDoc}
57
-     * @see \Psr\Http\Server\RequestHandlerInterface::handle()
58
-     */
59
-    public function handle(ServerRequestInterface $request): ResponseInterface
60
-    {
61
-        $this->layout = 'layouts/ajax';
55
+	/**
56
+	 * {@inheritDoc}
57
+	 * @see \Psr\Http\Server\RequestHandlerInterface::handle()
58
+	 */
59
+	public function handle(ServerRequestInterface $request): ResponseInterface
60
+	{
61
+		$this->layout = 'layouts/ajax';
62 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();
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 67
 
68
-        $adapter_id = Validator::attributes($request)->integer('adapter_id', -1);
69
-        $map_adapter = $this->mapadapter_data_service->find($adapter_id);
68
+		$adapter_id = Validator::attributes($request)->integer('adapter_id', -1);
69
+		$map_adapter = $this->mapadapter_data_service->find($adapter_id);
70 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
-            }
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 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
-        }
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 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
-        }
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 94
 
95
-        return $this->viewResponse('layouts/ajax', [
96
-            'content' => $mapper->config()->configContent($this->module, $tree)
97
-        ]);
98
-    }
95
+		return $this->viewResponse('layouts/ajax', [
96
+			'content' => $mapper->config()->configContent($this->module, $tree)
97
+		]);
98
+	}
99 99
 }
Please login to merge, or discard this patch.
app/Module/GeoDispersion/Http/RequestHandlers/MapAdapterAddPage.php 2 patches
Indentation   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -33,68 +33,68 @@
 block discarded – undo
33 33
  */
34 34
 class MapAdapterAddPage implements RequestHandlerInterface
35 35
 {
36
-    use ViewResponseTrait;
36
+	use ViewResponseTrait;
37 37
 
38
-    private ?GeoDispersionModule $module;
39
-    private GeoAnalysisViewDataService $geoview_data_service;
40
-    private MapDefinitionsService $map_definition_service;
41
-    private PlaceMapperService $place_mapper_service;
38
+	private ?GeoDispersionModule $module;
39
+	private GeoAnalysisViewDataService $geoview_data_service;
40
+	private MapDefinitionsService $map_definition_service;
41
+	private PlaceMapperService $place_mapper_service;
42 42
 
43
-    /**
44
-     * Constructor for MapAdapterAddPage Request Handler
45
-     *
46
-     * @param ModuleService $module_service
47
-     * @param GeoAnalysisViewDataService $geoview_data_service
48
-     * @param MapDefinitionsService $map_definition_service
49
-     * @param PlaceMapperService $place_mapper_service
50
-     */
51
-    public function __construct(
52
-        ModuleService $module_service,
53
-        GeoAnalysisViewDataService $geoview_data_service,
54
-        MapDefinitionsService $map_definition_service,
55
-        PlaceMapperService $place_mapper_service
56
-    ) {
57
-        $this->module = $module_service->findByInterface(GeoDispersionModule::class)->first();
58
-        $this->geoview_data_service = $geoview_data_service;
59
-        $this->map_definition_service = $map_definition_service;
60
-        $this->place_mapper_service = $place_mapper_service;
61
-    }
43
+	/**
44
+	 * Constructor for MapAdapterAddPage Request Handler
45
+	 *
46
+	 * @param ModuleService $module_service
47
+	 * @param GeoAnalysisViewDataService $geoview_data_service
48
+	 * @param MapDefinitionsService $map_definition_service
49
+	 * @param PlaceMapperService $place_mapper_service
50
+	 */
51
+	public function __construct(
52
+		ModuleService $module_service,
53
+		GeoAnalysisViewDataService $geoview_data_service,
54
+		MapDefinitionsService $map_definition_service,
55
+		PlaceMapperService $place_mapper_service
56
+	) {
57
+		$this->module = $module_service->findByInterface(GeoDispersionModule::class)->first();
58
+		$this->geoview_data_service = $geoview_data_service;
59
+		$this->map_definition_service = $map_definition_service;
60
+		$this->place_mapper_service = $place_mapper_service;
61
+	}
62 62
 
63
-    /**
64
-     * {@inheritDoc}
65
-     * @see \Psr\Http\Server\RequestHandlerInterface::handle()
66
-     */
67
-    public function handle(ServerRequestInterface $request): ResponseInterface
68
-    {
69
-        $this->layout = 'layouts/administration';
63
+	/**
64
+	 * {@inheritDoc}
65
+	 * @see \Psr\Http\Server\RequestHandlerInterface::handle()
66
+	 */
67
+	public function handle(ServerRequestInterface $request): ResponseInterface
68
+	{
69
+		$this->layout = 'layouts/administration';
70 70
 
71
-        if ($this->module === null) {
72
-            throw new HttpNotFoundException(I18N::translate('The attached module could not be found.'));
73
-        }
71
+		if ($this->module === null) {
72
+			throw new HttpNotFoundException(I18N::translate('The attached module could not be found.'));
73
+		}
74 74
 
75
-        $tree = Validator::attributes($request)->tree();
75
+		$tree = Validator::attributes($request)->tree();
76 76
 
77
-        $view_id = Validator::attributes($request)->integer('view_id', -1);
78
-        $view = $this->geoview_data_service->find($tree, $view_id, true);
77
+		$view_id = Validator::attributes($request)->integer('view_id', -1);
78
+		$view = $this->geoview_data_service->find($tree, $view_id, true);
79 79
 
80
-        if ($view === null) {
81
-            throw new HttpNotFoundException(
82
-                I18N::translate('The geographical dispersion analysis view could not be found.')
83
-            );
84
-        }
80
+		if ($view === null) {
81
+			throw new HttpNotFoundException(
82
+				I18N::translate('The geographical dispersion analysis view could not be found.')
83
+			);
84
+		}
85 85
 
86
-        return $this->viewResponse($this->module->name() . '::admin/map-adapter-edit', [
87
-            'module'            =>  $this->module,
88
-            'title'             =>  I18N::translate('Add a map configuration'),
89
-            'tree'              =>  $tree,
90
-            'view_id'           =>  $view_id,
91
-            'map_adapter'       =>  null,
92
-            'maps_list'         =>  $this->map_definition_service->all(),
93
-            'mappers_list'      =>  $this->place_mapper_service->all(),
94
-            'route_edit'        =>  route(MapAdapterAddAction::class, [
95
-                                        'tree'      => $tree->name(),
96
-                                        'view_id'   => $view_id
97
-                                    ])
98
-        ]);
99
-    }
86
+		return $this->viewResponse($this->module->name() . '::admin/map-adapter-edit', [
87
+			'module'            =>  $this->module,
88
+			'title'             =>  I18N::translate('Add a map configuration'),
89
+			'tree'              =>  $tree,
90
+			'view_id'           =>  $view_id,
91
+			'map_adapter'       =>  null,
92
+			'maps_list'         =>  $this->map_definition_service->all(),
93
+			'mappers_list'      =>  $this->place_mapper_service->all(),
94
+			'route_edit'        =>  route(MapAdapterAddAction::class, [
95
+										'tree'      => $tree->name(),
96
+										'view_id'   => $view_id
97
+									])
98
+		]);
99
+	}
100 100
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -83,7 +83,7 @@
 block discarded – undo
83 83
             );
84 84
         }
85 85
 
86
-        return $this->viewResponse($this->module->name() . '::admin/map-adapter-edit', [
86
+        return $this->viewResponse($this->module->name().'::admin/map-adapter-edit', [
87 87
             'module'            =>  $this->module,
88 88
             'title'             =>  I18N::translate('Add a map configuration'),
89 89
             'tree'              =>  $tree,
Please login to merge, or discard this patch.
app/Module/GeoDispersion/Http/RequestHandlers/GeoAnalysisViewPage.php 2 patches
Indentation   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -32,42 +32,42 @@
 block discarded – undo
32 32
  */
33 33
 class GeoAnalysisViewPage implements RequestHandlerInterface
34 34
 {
35
-    use ViewResponseTrait;
35
+	use ViewResponseTrait;
36 36
 
37
-    private ?GeoDispersionModule $module;
38
-    private GeoAnalysisViewDataService $geoviewdata_service;
37
+	private ?GeoDispersionModule $module;
38
+	private GeoAnalysisViewDataService $geoviewdata_service;
39 39
 
40
-    /**
41
-     * Constructor for GeoAnalysisViewPage Request Handler
42
-     *
43
-     * @param ModuleService $module_service
44
-     */
45
-    public function __construct(
46
-        ModuleService $module_service,
47
-        GeoAnalysisViewDataService $geoviewdata_service
48
-    ) {
49
-        $this->module = $module_service->findByInterface(GeoDispersionModule::class)->first();
50
-        $this->geoviewdata_service = $geoviewdata_service;
51
-    }
40
+	/**
41
+	 * Constructor for GeoAnalysisViewPage Request Handler
42
+	 *
43
+	 * @param ModuleService $module_service
44
+	 */
45
+	public function __construct(
46
+		ModuleService $module_service,
47
+		GeoAnalysisViewDataService $geoviewdata_service
48
+	) {
49
+		$this->module = $module_service->findByInterface(GeoDispersionModule::class)->first();
50
+		$this->geoviewdata_service = $geoviewdata_service;
51
+	}
52 52
 
53
-    /**
54
-     * {@inheritDoc}
55
-     * @see \Psr\Http\Server\RequestHandlerInterface::handle()
56
-     */
57
-    public function handle(ServerRequestInterface $request): ResponseInterface
58
-    {
59
-        if ($this->module === null) {
60
-            throw new HttpNotFoundException(I18N::translate('The attached module could not be found.'));
61
-        }
53
+	/**
54
+	 * {@inheritDoc}
55
+	 * @see \Psr\Http\Server\RequestHandlerInterface::handle()
56
+	 */
57
+	public function handle(ServerRequestInterface $request): ResponseInterface
58
+	{
59
+		if ($this->module === null) {
60
+			throw new HttpNotFoundException(I18N::translate('The attached module could not be found.'));
61
+		}
62 62
 
63
-        $tree = Validator::attributes($request)->tree();
64
-        $view_id = Validator::attributes($request)->integer('view_id', 0);
63
+		$tree = Validator::attributes($request)->tree();
64
+		$view_id = Validator::attributes($request)->integer('view_id', 0);
65 65
 
66
-        return $this->viewResponse($this->module->name() . '::geoanalysisview-page', [
67
-            'module_name'           =>  $this->module->name(),
68
-            'title'                 =>  I18N::translate('Geographical dispersion'),
69
-            'tree'                  =>  $tree,
70
-            'view'                  =>  $this->geoviewdata_service->find($tree, $view_id)
71
-        ]);
72
-    }
66
+		return $this->viewResponse($this->module->name() . '::geoanalysisview-page', [
67
+			'module_name'           =>  $this->module->name(),
68
+			'title'                 =>  I18N::translate('Geographical dispersion'),
69
+			'tree'                  =>  $tree,
70
+			'view'                  =>  $this->geoviewdata_service->find($tree, $view_id)
71
+		]);
72
+	}
73 73
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -63,7 +63,7 @@
 block discarded – undo
63 63
         $tree = Validator::attributes($request)->tree();
64 64
         $view_id = Validator::attributes($request)->integer('view_id', 0);
65 65
 
66
-        return $this->viewResponse($this->module->name() . '::geoanalysisview-page', [
66
+        return $this->viewResponse($this->module->name().'::geoanalysisview-page', [
67 67
             'module_name'           =>  $this->module->name(),
68 68
             'title'                 =>  I18N::translate('Geographical dispersion'),
69 69
             'tree'                  =>  $tree,
Please login to merge, or discard this patch.
app/Module/GeoDispersion/Http/RequestHandlers/GeoAnalysisViewEditPage.php 2 patches
Indentation   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -32,64 +32,64 @@
 block discarded – undo
32 32
  */
33 33
 class GeoAnalysisViewEditPage implements RequestHandlerInterface
34 34
 {
35
-    use ViewResponseTrait;
35
+	use ViewResponseTrait;
36 36
 
37
-    private ?GeoDispersionModule $module;
38
-    private GeoAnalysisViewDataService $geoview_data_service;
39
-    private GeoAnalysisService $geoanalysis_service;
40
-    private GeoAnalysisDataService $geoanalysis_data_service;
37
+	private ?GeoDispersionModule $module;
38
+	private GeoAnalysisViewDataService $geoview_data_service;
39
+	private GeoAnalysisService $geoanalysis_service;
40
+	private GeoAnalysisDataService $geoanalysis_data_service;
41 41
 
42
-    /**
43
-     * Constructor for GeoAnalysisViewEditPage Request Handler
44
-     *
45
-     * @param ModuleService $module_service
46
-     * @param GeoAnalysisViewDataService $geoview_data_service
47
-     * @param GeoAnalysisService $geoanalysis_service
48
-     * @param GeoAnalysisDataService $geoanalysis_data_service
49
-     */
50
-    public function __construct(
51
-        ModuleService $module_service,
52
-        GeoAnalysisViewDataService $geoview_data_service,
53
-        GeoAnalysisService $geoanalysis_service,
54
-        GeoAnalysisDataService $geoanalysis_data_service
55
-    ) {
56
-        $this->module = $module_service->findByInterface(GeoDispersionModule::class)->first();
57
-        $this->geoview_data_service = $geoview_data_service;
58
-        $this->geoanalysis_service = $geoanalysis_service;
59
-        $this->geoanalysis_data_service = $geoanalysis_data_service;
60
-    }
42
+	/**
43
+	 * Constructor for GeoAnalysisViewEditPage Request Handler
44
+	 *
45
+	 * @param ModuleService $module_service
46
+	 * @param GeoAnalysisViewDataService $geoview_data_service
47
+	 * @param GeoAnalysisService $geoanalysis_service
48
+	 * @param GeoAnalysisDataService $geoanalysis_data_service
49
+	 */
50
+	public function __construct(
51
+		ModuleService $module_service,
52
+		GeoAnalysisViewDataService $geoview_data_service,
53
+		GeoAnalysisService $geoanalysis_service,
54
+		GeoAnalysisDataService $geoanalysis_data_service
55
+	) {
56
+		$this->module = $module_service->findByInterface(GeoDispersionModule::class)->first();
57
+		$this->geoview_data_service = $geoview_data_service;
58
+		$this->geoanalysis_service = $geoanalysis_service;
59
+		$this->geoanalysis_data_service = $geoanalysis_data_service;
60
+	}
61 61
 
62
-    /**
63
-     * {@inheritDoc}
64
-     * @see \Psr\Http\Server\RequestHandlerInterface::handle()
65
-     */
66
-    public function handle(ServerRequestInterface $request): ResponseInterface
67
-    {
68
-        $this->layout = 'layouts/administration';
62
+	/**
63
+	 * {@inheritDoc}
64
+	 * @see \Psr\Http\Server\RequestHandlerInterface::handle()
65
+	 */
66
+	public function handle(ServerRequestInterface $request): ResponseInterface
67
+	{
68
+		$this->layout = 'layouts/administration';
69 69
 
70
-        if ($this->module === null) {
71
-            throw new HttpNotFoundException(I18N::translate('The attached module could not be found.'));
72
-        }
70
+		if ($this->module === null) {
71
+			throw new HttpNotFoundException(I18N::translate('The attached module could not be found.'));
72
+		}
73 73
 
74
-        $tree = Validator::attributes($request)->tree();
74
+		$tree = Validator::attributes($request)->tree();
75 75
 
76
-        $view_id = Validator::attributes($request)->integer('view_id', -1);
77
-        $view = $this->geoview_data_service->find($tree, $view_id, true);
76
+		$view_id = Validator::attributes($request)->integer('view_id', -1);
77
+		$view = $this->geoview_data_service->find($tree, $view_id, true);
78 78
 
79
-        if ($view === null) {
80
-            throw new HttpNotFoundException(
81
-                I18N::translate('The geographical dispersion analysis view could not be found.')
82
-            );
83
-        }
79
+		if ($view === null) {
80
+			throw new HttpNotFoundException(
81
+				I18N::translate('The geographical dispersion analysis view could not be found.')
82
+			);
83
+		}
84 84
 
85
-        return $this->viewResponse($this->module->name() . '::admin/view-edit', [
86
-            'module'        =>  $this->module,
87
-            'title'         =>  I18N::translate('Edit the geographical dispersion analysis view - %s', $view->type()),
88
-            'tree'          =>  $tree,
89
-            'view'          =>  $view,
90
-            'geoanalysis_list'  =>  $this->geoanalysis_service->all(),
91
-            'place_example'     =>  $this->geoanalysis_data_service->placeHierarchyExample($tree),
92
-            'global_settings'   =>  $view->globalSettingsContent($this->module)
93
-        ]);
94
-    }
85
+		return $this->viewResponse($this->module->name() . '::admin/view-edit', [
86
+			'module'        =>  $this->module,
87
+			'title'         =>  I18N::translate('Edit the geographical dispersion analysis view - %s', $view->type()),
88
+			'tree'          =>  $tree,
89
+			'view'          =>  $view,
90
+			'geoanalysis_list'  =>  $this->geoanalysis_service->all(),
91
+			'place_example'     =>  $this->geoanalysis_data_service->placeHierarchyExample($tree),
92
+			'global_settings'   =>  $view->globalSettingsContent($this->module)
93
+		]);
94
+	}
95 95
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -82,7 +82,7 @@
 block discarded – undo
82 82
             );
83 83
         }
84 84
 
85
-        return $this->viewResponse($this->module->name() . '::admin/view-edit', [
85
+        return $this->viewResponse($this->module->name().'::admin/view-edit', [
86 86
             'module'        =>  $this->module,
87 87
             'title'         =>  I18N::translate('Edit the geographical dispersion analysis view - %s', $view->type()),
88 88
             'tree'          =>  $tree,
Please login to merge, or discard this patch.
app/Module/GeoDispersion/PlaceMappers/TopFilteredPlaceMapperTrait.php 1 patch
Indentation   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -21,51 +21,51 @@
 block discarded – undo
21 21
  */
22 22
 trait TopFilteredPlaceMapperTrait
23 23
 {
24
-    /**
25
-     * @var Place[] $top_places
26
-     */
27
-    private array $top_places = [];
24
+	/**
25
+	 * @var Place[] $top_places
26
+	 */
27
+	private array $top_places = [];
28 28
 
29
-    /**
30
-     * Get the list of top level places.
31
-     *
32
-     * @return Place[]
33
-     */
34
-    public function topPlaces(): array
35
-    {
36
-        return $this->top_places;
37
-    }
29
+	/**
30
+	 * Get the list of top level places.
31
+	 *
32
+	 * @return Place[]
33
+	 */
34
+	public function topPlaces(): array
35
+	{
36
+		return $this->top_places;
37
+	}
38 38
 
39
-    /**
40
-     * Set the list of defined top level places.
41
-     *
42
-     * @param Place[] $top_places
43
-     */
44
-    public function setTopPlaces(array $top_places): void
45
-    {
46
-        $this->top_places = collect($top_places)
47
-            ->filter(
48
-                /** @psalm-suppress MissingClosureParamType */
49
-                fn($top_places): bool => $top_places instanceof Place
50
-            )->toArray();
51
-    }
39
+	/**
40
+	 * Set the list of defined top level places.
41
+	 *
42
+	 * @param Place[] $top_places
43
+	 */
44
+	public function setTopPlaces(array $top_places): void
45
+	{
46
+		$this->top_places = collect($top_places)
47
+			->filter(
48
+				/** @psalm-suppress MissingClosureParamType */
49
+				fn($top_places): bool => $top_places instanceof Place
50
+			)->toArray();
51
+	}
52 52
 
53
-    /**
54
-     * Check whether a Place belongs to one of the defined top places.
55
-     *
56
-     * @param Place $place
57
-     * @return bool
58
-     */
59
-    protected function belongsToTopLevels(Place $place): bool
60
-    {
61
-        foreach ($this->top_places as $top_place) {
62
-            if (
63
-                $top_place->tree()->id() === $place->tree()->id() &&
64
-                str_ends_with($place->gedcomName(), $top_place->gedcomName())
65
-            ) {
66
-                    return true;
67
-            }
68
-        }
69
-        return false;
70
-    }
53
+	/**
54
+	 * Check whether a Place belongs to one of the defined top places.
55
+	 *
56
+	 * @param Place $place
57
+	 * @return bool
58
+	 */
59
+	protected function belongsToTopLevels(Place $place): bool
60
+	{
61
+		foreach ($this->top_places as $top_place) {
62
+			if (
63
+				$top_place->tree()->id() === $place->tree()->id() &&
64
+				str_ends_with($place->gedcomName(), $top_place->gedcomName())
65
+			) {
66
+					return true;
67
+			}
68
+		}
69
+		return false;
70
+	}
71 71
 }
Please login to merge, or discard this patch.
app/Module/GeoDispersion/Services/MapDefinitionsService.php 2 patches
Indentation   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -25,51 +25,51 @@
 block discarded – undo
25 25
  */
26 26
 class MapDefinitionsService
27 27
 {
28
-    private ModuleService $module_service;
28
+	private ModuleService $module_service;
29 29
 
30
-    /**
31
-     * Constructor for MapDefinitionsService
32
-     *
33
-     * @param ModuleService $module_service
34
-     */
35
-    public function __construct(ModuleService $module_service)
36
-    {
37
-        $this->module_service = $module_service;
38
-    }
30
+	/**
31
+	 * Constructor for MapDefinitionsService
32
+	 *
33
+	 * @param ModuleService $module_service
34
+	 */
35
+	public function __construct(ModuleService $module_service)
36
+	{
37
+		$this->module_service = $module_service;
38
+	}
39 39
 
40
-    /**
41
-     * Find a map definition by ID.
42
-     *
43
-     * @param string $id
44
-     * @return MapDefinitionInterface|NULL
45
-     */
46
-    public function find(string $id): ?MapDefinitionInterface
47
-    {
48
-        return $this->all()->get($id);
49
-    }
40
+	/**
41
+	 * Find a map definition by ID.
42
+	 *
43
+	 * @param string $id
44
+	 * @return MapDefinitionInterface|NULL
45
+	 */
46
+	public function find(string $id): ?MapDefinitionInterface
47
+	{
48
+		return $this->all()->get($id);
49
+	}
50 50
 
51
-    /**
52
-     * Get all map definitions available.
53
-     *
54
-     * {@internal The list is generated based on the modules exposing ModuleMapDefinitionProviderInterface,
55
-     * and the result is cached}
56
-     *
57
-     * @param bool $include_disabled
58
-     * @return Collection<string, MapDefinitionInterface>
59
-     */
60
-    public function all(bool $include_disabled = false): Collection
61
-    {
62
-        return Registry::cache()->array()->remember(
63
-            'maj-geodisp-maps-all',
64
-            function () use ($include_disabled): Collection {
65
-                /** @var Collection<string, MapDefinitionInterface> $map_definitions */
66
-                $map_definitions = $this->module_service
67
-                    ->findByInterface(ModuleMapDefinitionProviderInterface::class, $include_disabled)
68
-                    ->flatMap(fn(ModuleMapDefinitionProviderInterface $module) => $module->listMapDefinition())
69
-                    ->mapWithKeys(fn(MapDefinitionInterface $map) => [ $map->id() => $map ]);
51
+	/**
52
+	 * Get all map definitions available.
53
+	 *
54
+	 * {@internal The list is generated based on the modules exposing ModuleMapDefinitionProviderInterface,
55
+	 * and the result is cached}
56
+	 *
57
+	 * @param bool $include_disabled
58
+	 * @return Collection<string, MapDefinitionInterface>
59
+	 */
60
+	public function all(bool $include_disabled = false): Collection
61
+	{
62
+		return Registry::cache()->array()->remember(
63
+			'maj-geodisp-maps-all',
64
+			function () use ($include_disabled): Collection {
65
+				/** @var Collection<string, MapDefinitionInterface> $map_definitions */
66
+				$map_definitions = $this->module_service
67
+					->findByInterface(ModuleMapDefinitionProviderInterface::class, $include_disabled)
68
+					->flatMap(fn(ModuleMapDefinitionProviderInterface $module) => $module->listMapDefinition())
69
+					->mapWithKeys(fn(MapDefinitionInterface $map) => [ $map->id() => $map ]);
70 70
 
71
-                return $map_definitions;
72
-            }
73
-        );
74
-    }
71
+				return $map_definitions;
72
+			}
73
+		);
74
+	}
75 75
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -61,12 +61,12 @@
 block discarded – undo
61 61
     {
62 62
         return Registry::cache()->array()->remember(
63 63
             'maj-geodisp-maps-all',
64
-            function () use ($include_disabled): Collection {
64
+            function() use ($include_disabled): Collection {
65 65
                 /** @var Collection<string, MapDefinitionInterface> $map_definitions */
66 66
                 $map_definitions = $this->module_service
67 67
                     ->findByInterface(ModuleMapDefinitionProviderInterface::class, $include_disabled)
68 68
                     ->flatMap(fn(ModuleMapDefinitionProviderInterface $module) => $module->listMapDefinition())
69
-                    ->mapWithKeys(fn(MapDefinitionInterface $map) => [ $map->id() => $map ]);
69
+                    ->mapWithKeys(fn(MapDefinitionInterface $map) => [$map->id() => $map]);
70 70
 
71 71
                 return $map_definitions;
72 72
             }
Please login to merge, or discard this patch.
app/Module/GeoDispersion/Model/GeoAnalysisMapAdapter.php 2 patches
Indentation   +185 added lines, -185 removed lines patch added patch discarded remove patch
@@ -29,189 +29,189 @@
 block discarded – undo
29 29
  */
30 30
 class GeoAnalysisMapAdapter
31 31
 {
32
-    private int $id;
33
-    private int $view_id;
34
-    private MapDefinitionInterface $map;
35
-    private PlaceMapperInterface $place_mapper;
36
-    private MapViewConfigInterface $config;
37
-
38
-    /**
39
-     * Constructor for GeoAnalysisMapAdapter
40
-     *
41
-     * @param int $id
42
-     * @param MapDefinitionInterface $map
43
-     * @param PlaceMapperInterface $mapper
44
-     * @param MapViewConfigInterface $config
45
-     */
46
-    public function __construct(
47
-        int $id,
48
-        int $view_id,
49
-        MapDefinitionInterface $map,
50
-        PlaceMapperInterface $mapper,
51
-        MapViewConfigInterface $config
52
-    ) {
53
-        $this->id = $id;
54
-        $this->view_id = $view_id;
55
-        $this->map = $map;
56
-        $this->place_mapper = $mapper;
57
-        $this->config = $config;
58
-        $this->place_mapper->setConfig($this->config->mapperConfig());
59
-        $this->place_mapper->setData('map', $map);
60
-        $this->place_mapper->boot();
61
-    }
62
-
63
-    /**
64
-     * Create a copy of the GeoAnalysisMapAdapter with new properties.
65
-     *
66
-     * @param MapDefinitionInterface $map
67
-     * @param PlaceMapperInterface $mapper
68
-     * @param string $mapping_property
69
-     * @return static
70
-     */
71
-    public function with(
72
-        MapDefinitionInterface $map,
73
-        PlaceMapperInterface $mapper,
74
-        string $mapping_property
75
-    ): self {
76
-        $new = clone $this;
77
-        $new->map = $map;
78
-        $new->place_mapper = $mapper;
79
-        $new->config = $this->config->with($mapping_property, $mapper->config());
80
-        return $new;
81
-    }
82
-
83
-    /**
84
-     * Get the GeoAnalysisMapAdapter ID
85
-     *
86
-     * @return int
87
-     */
88
-    public function id(): int
89
-    {
90
-        return $this->id;
91
-    }
92
-
93
-    /**
94
-     * Get the ID of the associated GeoAnalysisView
95
-     *
96
-     * @return int
97
-     */
98
-    public function geoAnalysisViewId(): int
99
-    {
100
-        return $this->view_id;
101
-    }
102
-
103
-    /**
104
-     * Get the associated target map
105
-     *
106
-     * @return MapDefinitionInterface
107
-     */
108
-    public function map(): MapDefinitionInterface
109
-    {
110
-        return $this->map;
111
-    }
112
-
113
-    /**
114
-     * Get the Place Mapper used for the mapping
115
-     *
116
-     * @return PlaceMapperInterface
117
-     */
118
-    public function placeMapper(): PlaceMapperInterface
119
-    {
120
-        return $this->place_mapper;
121
-    }
122
-
123
-    /**
124
-     * Get the configuration of the Map View.
125
-     *
126
-     * @return MapViewConfigInterface
127
-     */
128
-    public function viewConfig(): MapViewConfigInterface
129
-    {
130
-        return $this->config;
131
-    }
132
-
133
-    /**
134
-     * Convert the geographical analysis result to a MapAdapter result for usage in the Map View
135
-     *
136
-     * @param GeoAnalysisResult $result
137
-     * @return MapAdapterResult
138
-     */
139
-    public function convert(GeoAnalysisResult $result): MapAdapterResult
140
-    {
141
-        $result = $result->copy();
142
-
143
-        $features = [];
144
-        list($features_data, $result) = $this->featureAnalysisData($result);
145
-
146
-        $places_found = $result->countFound();
147
-        foreach ($this->map->features() as $feature) {
148
-            $feature_id = $this->featureId($feature);
149
-            if ($feature_id !== null && $features_data->has($feature_id)) {
150
-                /** @var MapFeatureAnalysisData $feature_data */
151
-                $feature_data = $features_data->get($feature_id)->tagAsExisting();
152
-                $place_count = $feature_data->count();
153
-                $features[] = $feature
154
-                    ->withProperty('count', $place_count)
155
-                    ->withProperty('ratio', $places_found > 0 ? $place_count / $places_found : 0)
156
-                    ->withProperty(
157
-                        'places',
158
-                        $feature_data->places()
159
-                            ->map(fn(GeoAnalysisPlace $place): string => $place->place()->firstParts(1)->first())
160
-                            ->sort(I18N::comparator())
161
-                            ->toArray()
162
-                    );
163
-            } else {
164
-                $features[] = $feature;
165
-            }
166
-        }
167
-
168
-        $features_data
169
-            ->filter(fn(MapFeatureAnalysisData $data) => !$data->existsInMap())
170
-            ->each(
171
-                fn (MapFeatureAnalysisData $data) =>
172
-                    $data->places()->each(
173
-                        fn(GeoAnalysisPlace $place) => $result->exclude($place)
174
-                    )
175
-            );
176
-
177
-        return new MapAdapterResult($result, $features);
178
-    }
179
-
180
-    /**
181
-     * Populate the map features with the mapped Places and total count
182
-     *
183
-     * @param GeoAnalysisResult $result
184
-     * @return mixed[]
185
-     */
186
-    protected function featureAnalysisData(GeoAnalysisResult $result): array
187
-    {
188
-        $features_mapping = new Collection();
189
-
190
-        $byplaces = $result->knownPlaces();
191
-        $byplaces->each(function (GeoAnalysisResultItem $item) use ($features_mapping, $result): void {
192
-            $id = $this->place_mapper->map($item->place()->place(), $this->config->mapMappingProperty());
193
-
194
-            if ($id !== null && mb_strlen($id) > 0) {
195
-                $features_mapping->put(
196
-                    $id,
197
-                    $features_mapping->get($id, new MapFeatureAnalysisData())->add($item->place(), $item->count())
198
-                );
199
-            } else {
200
-                $result->exclude($item->place());
201
-            }
202
-        });
203
-
204
-        return [ $features_mapping, $result];
205
-    }
206
-
207
-    /**
208
-     * Get the value of the feature property used for the mapping
209
-     *
210
-     * @param Feature $feature
211
-     * @return string|NULL
212
-     */
213
-    protected function featureId(Feature $feature): ?string
214
-    {
215
-        return $feature->getProperty($this->config->mapMappingProperty());
216
-    }
32
+	private int $id;
33
+	private int $view_id;
34
+	private MapDefinitionInterface $map;
35
+	private PlaceMapperInterface $place_mapper;
36
+	private MapViewConfigInterface $config;
37
+
38
+	/**
39
+	 * Constructor for GeoAnalysisMapAdapter
40
+	 *
41
+	 * @param int $id
42
+	 * @param MapDefinitionInterface $map
43
+	 * @param PlaceMapperInterface $mapper
44
+	 * @param MapViewConfigInterface $config
45
+	 */
46
+	public function __construct(
47
+		int $id,
48
+		int $view_id,
49
+		MapDefinitionInterface $map,
50
+		PlaceMapperInterface $mapper,
51
+		MapViewConfigInterface $config
52
+	) {
53
+		$this->id = $id;
54
+		$this->view_id = $view_id;
55
+		$this->map = $map;
56
+		$this->place_mapper = $mapper;
57
+		$this->config = $config;
58
+		$this->place_mapper->setConfig($this->config->mapperConfig());
59
+		$this->place_mapper->setData('map', $map);
60
+		$this->place_mapper->boot();
61
+	}
62
+
63
+	/**
64
+	 * Create a copy of the GeoAnalysisMapAdapter with new properties.
65
+	 *
66
+	 * @param MapDefinitionInterface $map
67
+	 * @param PlaceMapperInterface $mapper
68
+	 * @param string $mapping_property
69
+	 * @return static
70
+	 */
71
+	public function with(
72
+		MapDefinitionInterface $map,
73
+		PlaceMapperInterface $mapper,
74
+		string $mapping_property
75
+	): self {
76
+		$new = clone $this;
77
+		$new->map = $map;
78
+		$new->place_mapper = $mapper;
79
+		$new->config = $this->config->with($mapping_property, $mapper->config());
80
+		return $new;
81
+	}
82
+
83
+	/**
84
+	 * Get the GeoAnalysisMapAdapter ID
85
+	 *
86
+	 * @return int
87
+	 */
88
+	public function id(): int
89
+	{
90
+		return $this->id;
91
+	}
92
+
93
+	/**
94
+	 * Get the ID of the associated GeoAnalysisView
95
+	 *
96
+	 * @return int
97
+	 */
98
+	public function geoAnalysisViewId(): int
99
+	{
100
+		return $this->view_id;
101
+	}
102
+
103
+	/**
104
+	 * Get the associated target map
105
+	 *
106
+	 * @return MapDefinitionInterface
107
+	 */
108
+	public function map(): MapDefinitionInterface
109
+	{
110
+		return $this->map;
111
+	}
112
+
113
+	/**
114
+	 * Get the Place Mapper used for the mapping
115
+	 *
116
+	 * @return PlaceMapperInterface
117
+	 */
118
+	public function placeMapper(): PlaceMapperInterface
119
+	{
120
+		return $this->place_mapper;
121
+	}
122
+
123
+	/**
124
+	 * Get the configuration of the Map View.
125
+	 *
126
+	 * @return MapViewConfigInterface
127
+	 */
128
+	public function viewConfig(): MapViewConfigInterface
129
+	{
130
+		return $this->config;
131
+	}
132
+
133
+	/**
134
+	 * Convert the geographical analysis result to a MapAdapter result for usage in the Map View
135
+	 *
136
+	 * @param GeoAnalysisResult $result
137
+	 * @return MapAdapterResult
138
+	 */
139
+	public function convert(GeoAnalysisResult $result): MapAdapterResult
140
+	{
141
+		$result = $result->copy();
142
+
143
+		$features = [];
144
+		list($features_data, $result) = $this->featureAnalysisData($result);
145
+
146
+		$places_found = $result->countFound();
147
+		foreach ($this->map->features() as $feature) {
148
+			$feature_id = $this->featureId($feature);
149
+			if ($feature_id !== null && $features_data->has($feature_id)) {
150
+				/** @var MapFeatureAnalysisData $feature_data */
151
+				$feature_data = $features_data->get($feature_id)->tagAsExisting();
152
+				$place_count = $feature_data->count();
153
+				$features[] = $feature
154
+					->withProperty('count', $place_count)
155
+					->withProperty('ratio', $places_found > 0 ? $place_count / $places_found : 0)
156
+					->withProperty(
157
+						'places',
158
+						$feature_data->places()
159
+							->map(fn(GeoAnalysisPlace $place): string => $place->place()->firstParts(1)->first())
160
+							->sort(I18N::comparator())
161
+							->toArray()
162
+					);
163
+			} else {
164
+				$features[] = $feature;
165
+			}
166
+		}
167
+
168
+		$features_data
169
+			->filter(fn(MapFeatureAnalysisData $data) => !$data->existsInMap())
170
+			->each(
171
+				fn (MapFeatureAnalysisData $data) =>
172
+					$data->places()->each(
173
+						fn(GeoAnalysisPlace $place) => $result->exclude($place)
174
+					)
175
+			);
176
+
177
+		return new MapAdapterResult($result, $features);
178
+	}
179
+
180
+	/**
181
+	 * Populate the map features with the mapped Places and total count
182
+	 *
183
+	 * @param GeoAnalysisResult $result
184
+	 * @return mixed[]
185
+	 */
186
+	protected function featureAnalysisData(GeoAnalysisResult $result): array
187
+	{
188
+		$features_mapping = new Collection();
189
+
190
+		$byplaces = $result->knownPlaces();
191
+		$byplaces->each(function (GeoAnalysisResultItem $item) use ($features_mapping, $result): void {
192
+			$id = $this->place_mapper->map($item->place()->place(), $this->config->mapMappingProperty());
193
+
194
+			if ($id !== null && mb_strlen($id) > 0) {
195
+				$features_mapping->put(
196
+					$id,
197
+					$features_mapping->get($id, new MapFeatureAnalysisData())->add($item->place(), $item->count())
198
+				);
199
+			} else {
200
+				$result->exclude($item->place());
201
+			}
202
+		});
203
+
204
+		return [ $features_mapping, $result];
205
+	}
206
+
207
+	/**
208
+	 * Get the value of the feature property used for the mapping
209
+	 *
210
+	 * @param Feature $feature
211
+	 * @return string|NULL
212
+	 */
213
+	protected function featureId(Feature $feature): ?string
214
+	{
215
+		return $feature->getProperty($this->config->mapMappingProperty());
216
+	}
217 217
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
                     ->withProperty(
157 157
                         'places',
158 158
                         $feature_data->places()
159
-                            ->map(fn(GeoAnalysisPlace $place): string => $place->place()->firstParts(1)->first())
159
+                            ->map(fn(GeoAnalysisPlace $place) : string => $place->place()->firstParts(1)->first())
160 160
                             ->sort(I18N::comparator())
161 161
                             ->toArray()
162 162
                     );
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
         $features_mapping = new Collection();
189 189
 
190 190
         $byplaces = $result->knownPlaces();
191
-        $byplaces->each(function (GeoAnalysisResultItem $item) use ($features_mapping, $result): void {
191
+        $byplaces->each(function(GeoAnalysisResultItem $item) use ($features_mapping, $result): void {
192 192
             $id = $this->place_mapper->map($item->place()->place(), $this->config->mapMappingProperty());
193 193
 
194 194
             if ($id !== null && mb_strlen($id) > 0) {
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
             }
202 202
         });
203 203
 
204
-        return [ $features_mapping, $result];
204
+        return [$features_mapping, $result];
205 205
     }
206 206
 
207 207
     /**
Please login to merge, or discard this patch.