Passed
Push — main ( c808ff...4e47c4 )
by Jonathan
13:05
created
app/Module/GeoDispersion/Services/MapDefinitionsService.php 1 patch
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.
app/Module/GeoDispersion/Model/GeoAnalysisMapAdapter.php 1 patch
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.
app/Module/GeoDispersion/Model/MapFeatureAnalysisData.php 1 patch
Indentation   +67 added lines, -67 removed lines patch added patch discarded remove patch
@@ -22,77 +22,77 @@
 block discarded – undo
22 22
  */
23 23
 class MapFeatureAnalysisData
24 24
 {
25
-    private int $count;
26
-    private bool $in_map;
27
-    /**
28
-     * @var Collection<GeoAnalysisPlace> $places
29
-     */
30
-    private Collection $places;
25
+	private int $count;
26
+	private bool $in_map;
27
+	/**
28
+	 * @var Collection<GeoAnalysisPlace> $places
29
+	 */
30
+	private Collection $places;
31 31
 
32
-    /**
33
-     * Constructor for MapFeatureAnalysisData
34
-     */
35
-    public function __construct()
36
-    {
37
-        $this->count = 0;
38
-        $this->places = new Collection();
39
-        $this->in_map = false;
40
-    }
32
+	/**
33
+	 * Constructor for MapFeatureAnalysisData
34
+	 */
35
+	public function __construct()
36
+	{
37
+		$this->count = 0;
38
+		$this->places = new Collection();
39
+		$this->in_map = false;
40
+	}
41 41
 
42
-    /**
43
-     * Get the list of places mapped to the feature
44
-     *
45
-     * @return Collection<GeoAnalysisPlace>
46
-     */
47
-    public function places(): Collection
48
-    {
49
-        return $this->places;
50
-    }
42
+	/**
43
+	 * Get the list of places mapped to the feature
44
+	 *
45
+	 * @return Collection<GeoAnalysisPlace>
46
+	 */
47
+	public function places(): Collection
48
+	{
49
+		return $this->places;
50
+	}
51 51
 
52
-    /**
53
-     * Get the count of analysis items occurring in the feature
54
-     *
55
-     * @return int
56
-     */
57
-    public function count(): int
58
-    {
59
-        return $this->count;
60
-    }
52
+	/**
53
+	 * Get the count of analysis items occurring in the feature
54
+	 *
55
+	 * @return int
56
+	 */
57
+	public function count(): int
58
+	{
59
+		return $this->count;
60
+	}
61 61
 
62
-    /**
63
-     * Check whether the feature exist in the target map
64
-     *
65
-     * @return bool
66
-     */
67
-    public function existsInMap(): bool
68
-    {
69
-        return $this->in_map;
70
-    }
62
+	/**
63
+	 * Check whether the feature exist in the target map
64
+	 *
65
+	 * @return bool
66
+	 */
67
+	public function existsInMap(): bool
68
+	{
69
+		return $this->in_map;
70
+	}
71 71
 
72
-    /**
73
-     * Confirm that the feature exist in the target map
74
-     *
75
-     * @return $this
76
-     */
77
-    public function tagAsExisting(): self
78
-    {
79
-        $this->in_map = true;
80
-        return $this;
81
-    }
72
+	/**
73
+	 * Confirm that the feature exist in the target map
74
+	 *
75
+	 * @return $this
76
+	 */
77
+	public function tagAsExisting(): self
78
+	{
79
+		$this->in_map = true;
80
+		return $this;
81
+	}
82 82
 
83
-    /**
84
-     * Add a GeoAnalysisPlace to the feature
85
-     *
86
-     * @param GeoAnalysisPlace $place
87
-     * @param int $count
88
-     * @return $this
89
-     */
90
-    public function add(GeoAnalysisPlace $place, int $count): self
91
-    {
92
-        if (!$place->isExcluded()) {
93
-            $this->places->add($place);
94
-            $this->count += $count;
95
-        }
96
-        return $this;
97
-    }
83
+	/**
84
+	 * Add a GeoAnalysisPlace to the feature
85
+	 *
86
+	 * @param GeoAnalysisPlace $place
87
+	 * @param int $count
88
+	 * @return $this
89
+	 */
90
+	public function add(GeoAnalysisPlace $place, int $count): self
91
+	{
92
+		if (!$place->isExcluded()) {
93
+			$this->places->add($place);
94
+			$this->count += $count;
95
+		}
96
+		return $this;
97
+	}
98 98
 }
Please login to merge, or discard this patch.
app/Module/GeoDispersion/Model/MapAdapterResult.php 1 patch
Indentation   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -24,57 +24,57 @@
 block discarded – undo
24 24
  */
25 25
 class MapAdapterResult
26 26
 {
27
-    private GeoAnalysisResult $result;
27
+	private GeoAnalysisResult $result;
28 28
 
29
-    /**
30
-     * @var array<int, \Brick\Geo\IO\GeoJSON\Feature> $features
31
-     */
32
-    private array $features;
29
+	/**
30
+	 * @var array<int, \Brick\Geo\IO\GeoJSON\Feature> $features
31
+	 */
32
+	private array $features;
33 33
 
34
-    /**
35
-     * Constructor for MapAdapterResult
36
-     *
37
-     * @param GeoAnalysisResult $result
38
-     * @param \Brick\Geo\IO\GeoJSON\Feature[] $features
39
-     */
40
-    final public function __construct(GeoAnalysisResult $result, array $features)
41
-    {
42
-        $this->result = $result;
43
-        $this->features = $features;
44
-    }
34
+	/**
35
+	 * Constructor for MapAdapterResult
36
+	 *
37
+	 * @param GeoAnalysisResult $result
38
+	 * @param \Brick\Geo\IO\GeoJSON\Feature[] $features
39
+	 */
40
+	final public function __construct(GeoAnalysisResult $result, array $features)
41
+	{
42
+		$this->result = $result;
43
+		$this->features = $features;
44
+	}
45 45
 
46
-    /**
47
-     * Get the GeoAnalysisResult after mapping of the places
48
-     *
49
-     * @return GeoAnalysisResult
50
-     */
51
-    public function geoAnalysisResult(): GeoAnalysisResult
52
-    {
53
-        return $this->result;
54
-    }
46
+	/**
47
+	 * Get the GeoAnalysisResult after mapping of the places
48
+	 *
49
+	 * @return GeoAnalysisResult
50
+	 */
51
+	public function geoAnalysisResult(): GeoAnalysisResult
52
+	{
53
+		return $this->result;
54
+	}
55 55
 
56
-    /**
57
-     * Get the list of features to display on the map
58
-     *
59
-     * @return array<int, \Brick\Geo\IO\GeoJSON\Feature>
60
-     */
61
-    public function features(): array
62
-    {
63
-        return $this->features;
64
-    }
56
+	/**
57
+	 * Get the list of features to display on the map
58
+	 *
59
+	 * @return array<int, \Brick\Geo\IO\GeoJSON\Feature>
60
+	 */
61
+	public function features(): array
62
+	{
63
+		return $this->features;
64
+	}
65 65
 
66
-    /**
67
-     * Merge the current MapAdapter with another.
68
-     * The current object is modified, not the second one.
69
-     *
70
-     * @param MapAdapterResult $other
71
-     * @return static
72
-     */
73
-    public function merge(MapAdapterResult $other): self
74
-    {
75
-        return new static(
76
-            $this->result->merge($other->result),
77
-            [...$this->features, ...$other->features]
78
-        );
79
-    }
66
+	/**
67
+	 * Merge the current MapAdapter with another.
68
+	 * The current object is modified, not the second one.
69
+	 *
70
+	 * @param MapAdapterResult $other
71
+	 * @return static
72
+	 */
73
+	public function merge(MapAdapterResult $other): self
74
+	{
75
+		return new static(
76
+			$this->result->merge($other->result),
77
+			[...$this->features, ...$other->features]
78
+		);
79
+	}
80 80
 }
Please login to merge, or discard this patch.
app/Module/MiscExtensions/Hooks/TitlesCardHook.php 1 patch
Indentation   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -25,68 +25,68 @@
 block discarded – undo
25 25
  */
26 26
 class TitlesCardHook implements NameAccordionExtenderInterface
27 27
 {
28
-    private ModuleInterface $module;
28
+	private ModuleInterface $module;
29 29
 
30
-    /**
31
-     * Constructor for TitlesCardHook
32
-     *
33
-     * @param ModuleInterface $module
34
-     */
35
-    public function __construct(ModuleInterface $module)
36
-    {
37
-        $this->module = $module;
38
-    }
30
+	/**
31
+	 * Constructor for TitlesCardHook
32
+	 *
33
+	 * @param ModuleInterface $module
34
+	 */
35
+	public function __construct(ModuleInterface $module)
36
+	{
37
+		$this->module = $module;
38
+	}
39 39
 
40
-    /**
41
-     * {@inheritDoc}
42
-     * @see \MyArtJaub\Webtrees\Contracts\Hooks\HookInterface::module()
43
-     */
44
-    public function module(): ModuleInterface
45
-    {
46
-        return $this->module;
47
-    }
40
+	/**
41
+	 * {@inheritDoc}
42
+	 * @see \MyArtJaub\Webtrees\Contracts\Hooks\HookInterface::module()
43
+	 */
44
+	public function module(): ModuleInterface
45
+	{
46
+		return $this->module;
47
+	}
48 48
 
49
-    /**
50
-     * {@inheritDoc}
51
-     * @see \MyArtJaub\Webtrees\Contracts\Hooks\NameAccordionExtenderInterface::accordionCard()
52
-     */
53
-    public function accordionCard(Individual $individual): string
54
-    {
55
-        $title_separator = $this->module->getPreference('MAJ_TITLE_PREFIX');
56
-        if ($title_separator === '') {
57
-            return '';
58
-        }
49
+	/**
50
+	 * {@inheritDoc}
51
+	 * @see \MyArtJaub\Webtrees\Contracts\Hooks\NameAccordionExtenderInterface::accordionCard()
52
+	 */
53
+	public function accordionCard(Individual $individual): string
54
+	{
55
+		$title_separator = $this->module->getPreference('MAJ_TITLE_PREFIX');
56
+		if ($title_separator === '') {
57
+			return '';
58
+		}
59 59
 
60
-        $titles = $this->individualTitles($individual, '/(.*?) ((' . $title_separator .  ')(.*))/i');
60
+		$titles = $this->individualTitles($individual, '/(.*?) ((' . $title_separator .  ')(.*))/i');
61 61
 
62
-        return count($titles) === 0 ? '' :
63
-            view($this->module()->name() . '::components/accordion-item-titles', [ 'titles' => $titles ]);
64
-    }
62
+		return count($titles) === 0 ? '' :
63
+			view($this->module()->name() . '::components/accordion-item-titles', [ 'titles' => $titles ]);
64
+	}
65 65
 
66
-    /**
67
-     * Extract the individual titles from the TITL tags.
68
-     * Split the title based on a pattern to identify the title and the land it refers to.
69
-     *
70
-     * @param Individual $individual
71
-     * @param string $pattern
72
-     * @return array<string, string[]>
73
-     */
74
-    protected function individualTitles(Individual $individual, string $pattern): array
75
-    {
76
-        $titles_list = [];
77
-        /** @var \Illuminate\Support\Collection<string> $titles */
78
-        $titles = $individual->facts(['TITL'])
79
-            ->sortByDesc(fn(Fact $fact) => $fact->date()->julianDay())
80
-            ->map(fn(Fact $fact) => $fact->value());
66
+	/**
67
+	 * Extract the individual titles from the TITL tags.
68
+	 * Split the title based on a pattern to identify the title and the land it refers to.
69
+	 *
70
+	 * @param Individual $individual
71
+	 * @param string $pattern
72
+	 * @return array<string, string[]>
73
+	 */
74
+	protected function individualTitles(Individual $individual, string $pattern): array
75
+	{
76
+		$titles_list = [];
77
+		/** @var \Illuminate\Support\Collection<string> $titles */
78
+		$titles = $individual->facts(['TITL'])
79
+			->sortByDesc(fn(Fact $fact) => $fact->date()->julianDay())
80
+			->map(fn(Fact $fact) => $fact->value());
81 81
 
82
-        foreach ($titles as $title) {
83
-            if (preg_match($pattern, $title, $match) === 1) {
84
-                /** @var array<int, string> $match */
85
-                $titles_list[$match[1]][] = trim($match[2]);
86
-            } else {
87
-                $titles_list[$title][] = '';
88
-            }
89
-        }
90
-        return $titles_list;
91
-    }
82
+		foreach ($titles as $title) {
83
+			if (preg_match($pattern, $title, $match) === 1) {
84
+				/** @var array<int, string> $match */
85
+				$titles_list[$match[1]][] = trim($match[2]);
86
+			} else {
87
+				$titles_list[$title][] = '';
88
+			}
89
+		}
90
+		return $titles_list;
91
+	}
92 92
 }
Please login to merge, or discard this patch.
app/Module/Certificates/Http/RequestHandlers/AutoCompleteFile.php 1 patch
Indentation   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -31,53 +31,53 @@
 block discarded – undo
31 31
  */
32 32
 class AutoCompleteFile extends AbstractAutocompleteHandler
33 33
 {
34
-    // Tell the browser to cache the results
35
-    protected const CACHE_LIFE = 10;
34
+	// Tell the browser to cache the results
35
+	protected const CACHE_LIFE = 10;
36 36
 
37
-    private ?CertificatesModule $module;
38
-    private CertificateFilesystemService $certif_filesystem;
39
-    private UrlObfuscatorService $url_obfuscator_service;
37
+	private ?CertificatesModule $module;
38
+	private CertificateFilesystemService $certif_filesystem;
39
+	private UrlObfuscatorService $url_obfuscator_service;
40 40
 
41
-    /**
42
-     * Constructor for AutoCompleteFile Request Handler
43
-     *
44
-     * @param ModuleService $module_service
45
-     * @param CertificateFilesystemService $certif_filesystem
46
-     * @param UrlObfuscatorService $url_obfuscator_service
47
-     * @param SearchService $search_service
48
-     */
49
-    public function __construct(
50
-        ModuleService $module_service,
51
-        CertificateFilesystemService $certif_filesystem,
52
-        UrlObfuscatorService $url_obfuscator_service,
53
-        SearchService $search_service
54
-    ) {
55
-        parent::__construct($search_service);
56
-        $this->module = $module_service->findByInterface(CertificatesModule::class)->first();
57
-        $this->certif_filesystem = $certif_filesystem;
58
-        $this->url_obfuscator_service = $url_obfuscator_service;
59
-    }
41
+	/**
42
+	 * Constructor for AutoCompleteFile Request Handler
43
+	 *
44
+	 * @param ModuleService $module_service
45
+	 * @param CertificateFilesystemService $certif_filesystem
46
+	 * @param UrlObfuscatorService $url_obfuscator_service
47
+	 * @param SearchService $search_service
48
+	 */
49
+	public function __construct(
50
+		ModuleService $module_service,
51
+		CertificateFilesystemService $certif_filesystem,
52
+		UrlObfuscatorService $url_obfuscator_service,
53
+		SearchService $search_service
54
+	) {
55
+		parent::__construct($search_service);
56
+		$this->module = $module_service->findByInterface(CertificatesModule::class)->first();
57
+		$this->certif_filesystem = $certif_filesystem;
58
+		$this->url_obfuscator_service = $url_obfuscator_service;
59
+	}
60 60
 
61
-    /**
62
-     * {@inheritDoc}
63
-     * @see \Fisharebest\Webtrees\Http\RequestHandlers\AbstractAutocompleteHandler::search()
64
-     */
65
-    protected function search(ServerRequestInterface $request): Collection
66
-    {
67
-        $tree = Validator::attributes($request)->tree();
68
-        $city = Validator::queryParams($request)->string('cityobf', '');
61
+	/**
62
+	 * {@inheritDoc}
63
+	 * @see \Fisharebest\Webtrees\Http\RequestHandlers\AbstractAutocompleteHandler::search()
64
+	 */
65
+	protected function search(ServerRequestInterface $request): Collection
66
+	{
67
+		$tree = Validator::attributes($request)->tree();
68
+		$city = Validator::queryParams($request)->string('cityobf', '');
69 69
 
70
-        if ($this->module === null || $city === '' || !$this->url_obfuscator_service->tryDeobfuscate($city)) {
71
-            return collect();
72
-        }
70
+		if ($this->module === null || $city === '' || !$this->url_obfuscator_service->tryDeobfuscate($city)) {
71
+			return collect();
72
+		}
73 73
 
74
-        $query  =  Validator::attributes($request)->string('query', '');
74
+		$query  =  Validator::attributes($request)->string('query', '');
75 75
 
76
-        /** @var Collection<int, string> $results */
77
-        $results =  $this->certif_filesystem
78
-            ->certificatesForCityContaining($tree, $city, $query)
79
-            ->map(fn(Certificate $certificate): string => $certificate->filename());
76
+		/** @var Collection<int, string> $results */
77
+		$results =  $this->certif_filesystem
78
+			->certificatesForCityContaining($tree, $city, $query)
79
+			->map(fn(Certificate $certificate): string => $certificate->filename());
80 80
 
81
-        return $results;
82
-    }
81
+		return $results;
82
+	}
83 83
 }
Please login to merge, or discard this patch.
app/Module/Certificates/Http/RequestHandlers/AdminConfigPage.php 1 patch
Indentation   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -35,56 +35,56 @@
 block discarded – undo
35 35
  */
36 36
 class AdminConfigPage implements RequestHandlerInterface
37 37
 {
38
-    use ViewResponseTrait;
38
+	use ViewResponseTrait;
39 39
 
40
-    private ?CertificatesModule $module;
41
-    private TreeService $tree_service;
40
+	private ?CertificatesModule $module;
41
+	private TreeService $tree_service;
42 42
 
43
-    /**
44
-     * Constructor for Admin Config page request handler
45
-     *
46
-     * @param ModuleService $module_service
47
-     */
48
-    public function __construct(ModuleService $module_service, TreeService $tree_service)
49
-    {
50
-        $this->module = $module_service->findByInterface(CertificatesModule::class)->first();
51
-        $this->tree_service = $tree_service;
52
-    }
43
+	/**
44
+	 * Constructor for Admin Config page request handler
45
+	 *
46
+	 * @param ModuleService $module_service
47
+	 */
48
+	public function __construct(ModuleService $module_service, TreeService $tree_service)
49
+	{
50
+		$this->module = $module_service->findByInterface(CertificatesModule::class)->first();
51
+		$this->tree_service = $tree_service;
52
+	}
53 53
 
54
-    /**
55
-     * {@inheritDoc}
56
-     * @see \Psr\Http\Server\RequestHandlerInterface::handle()
57
-     */
58
-    public function handle(ServerRequestInterface $request): ResponseInterface
59
-    {
60
-        $this->layout = 'layouts/administration';
54
+	/**
55
+	 * {@inheritDoc}
56
+	 * @see \Psr\Http\Server\RequestHandlerInterface::handle()
57
+	 */
58
+	public function handle(ServerRequestInterface $request): ResponseInterface
59
+	{
60
+		$this->layout = 'layouts/administration';
61 61
 
62
-        if ($this->module === null) {
63
-            throw new HttpNotFoundException(I18N::translate('The attached module could not be found.'));
64
-        }
62
+		if ($this->module === null) {
63
+			throw new HttpNotFoundException(I18N::translate('The attached module could not be found.'));
64
+		}
65 65
 
66
-        $user = Validator::attributes($request)->user();
66
+		$user = Validator::attributes($request)->user();
67 67
 
68
-        $all_trees = $this->tree_service->all()->filter(fn(Tree $tree) => Auth::isManager($tree, $user));
69
-        if ($all_trees->count() === 0) {
70
-            throw new HttpAccessDeniedException();
71
-        }
68
+		$all_trees = $this->tree_service->all()->filter(fn(Tree $tree) => Auth::isManager($tree, $user));
69
+		if ($all_trees->count() === 0) {
70
+			throw new HttpAccessDeniedException();
71
+		}
72 72
 
73
-        $tree = Validator::attributes($request)->treeOptional('tree') ?? $all_trees->first();
73
+		$tree = Validator::attributes($request)->treeOptional('tree') ?? $all_trees->first();
74 74
 
75
-        $data_folder = Registry::filesystem()->dataName();
75
+		$data_folder = Registry::filesystem()->dataName();
76 76
 
77
-        $same_tree = fn(Tree $tree_collection): bool => $tree->id() === $tree_collection->id();
78
-        if (!$all_trees->contains($same_tree)) {
79
-            throw new HttpAccessDeniedException();
80
-        }
77
+		$same_tree = fn(Tree $tree_collection): bool => $tree->id() === $tree_collection->id();
78
+		if (!$all_trees->contains($same_tree)) {
79
+			throw new HttpAccessDeniedException();
80
+		}
81 81
 
82
-        return $this->viewResponse($this->module->name() . '::admin/config', [
83
-            'module_name'       =>  $this->module->name(),
84
-            'title'             =>  $this->module->title(),
85
-            'tree'              =>  $tree,
86
-            'other_trees'       =>  $all_trees->reject($same_tree),
87
-            'data_folder'       =>  $data_folder
88
-        ]);
89
-    }
82
+		return $this->viewResponse($this->module->name() . '::admin/config', [
83
+			'module_name'       =>  $this->module->name(),
84
+			'title'             =>  $this->module->title(),
85
+			'tree'              =>  $tree,
86
+			'other_trees'       =>  $all_trees->reject($same_tree),
87
+			'data_folder'       =>  $data_folder
88
+		]);
89
+	}
90 90
 }
Please login to merge, or discard this patch.
app/Module/Certificates/Http/RequestHandlers/CertificateImage.php 1 patch
Indentation   +102 added lines, -102 removed lines patch added patch discarded remove patch
@@ -38,106 +38,106 @@
 block discarded – undo
38 38
  */
39 39
 class CertificateImage implements RequestHandlerInterface
40 40
 {
41
-    private ?CertificatesModule $module;
42
-    private CertificateFilesystemService $certif_filesystem;
43
-    private CertificateImageFactory $certif_image_factory;
44
-    private CertificateDataService $certif_data_service;
45
-    private UrlObfuscatorService $url_obfuscator_service;
46
-
47
-    /**
48
-     * Constructor for Certificate Image Request Handler
49
-     *
50
-     * @param ModuleService $module_service
51
-     */
52
-    public function __construct(
53
-        ModuleService $module_service,
54
-        CertificateFilesystemService $certif_filesystem,
55
-        CertificateDataService $certif_data_service,
56
-        UrlObfuscatorService $url_obfuscator_service
57
-    ) {
58
-        $this->module = $module_service->findByInterface(CertificatesModule::class)->first();
59
-        $this->certif_filesystem = $certif_filesystem;
60
-        $this->certif_image_factory = new CertificateImageFactory($this->certif_filesystem);
61
-        $this->certif_data_service = $certif_data_service;
62
-        $this->url_obfuscator_service = $url_obfuscator_service;
63
-    }
64
-
65
-    /**
66
-     * {@inheritDoc}
67
-     * @see \Psr\Http\Server\RequestHandlerInterface::handle()
68
-     */
69
-    public function handle(ServerRequestInterface $request): ResponseInterface
70
-    {
71
-        if ($this->module === null) {
72
-            throw new HttpNotFoundException(I18N::translate('The attached module could not be found.'));
73
-        }
74
-
75
-        $tree = Validator::attributes($request)->tree();
76
-        $user = Validator::attributes($request)->user();
77
-
78
-        $certif_path = Validator::attributes($request)->string('cid', '');
79
-        $certificate = null;
80
-        if ($certif_path !== '' && $this->url_obfuscator_service->tryDeobfuscate($certif_path)) {
81
-            $certificate = $this->certif_filesystem->certificate($tree, $certif_path);
82
-        }
83
-
84
-        if ($certificate === null) {
85
-            return $this->certif_image_factory
86
-                ->replacementImageResponse((string) StatusCodeInterface::STATUS_NOT_FOUND)
87
-                ->withHeader('X-Image-Exception', I18N::translate('The certificate was not found in this family tree.'))
88
-            ;
89
-        }
90
-
91
-        $use_watermark = $this->certif_image_factory->certificateNeedsWatermark($certificate, $user);
92
-        $watermark = $use_watermark ? $this->watermark($request, $certificate) : null;
93
-
94
-        return $this->certif_image_factory->certificateFileResponse(
95
-            $certificate,
96
-            $use_watermark,
97
-            $watermark
98
-        );
99
-    }
100
-
101
-    /**
102
-     * Get watermark data for a certificate.
103
-     *
104
-     * @param ServerRequestInterface $request
105
-     * @param Certificate $certificate
106
-     * @return Watermark
107
-     */
108
-    private function watermark(ServerRequestInterface $request, Certificate $certificate): Watermark
109
-    {
110
-        $color = $certificate->tree()->getPreference('MAJ_CERTIF_WM_FONT_COLOR', Watermark::DEFAULT_COLOR);
111
-        $size = $certificate->tree()->getPreference('MAJ_CERTIF_WM_FONT_MAXSIZE');
112
-        $text = $this->watermarkText($request, $certificate);
113
-
114
-        return new Watermark($text, $color, is_numeric($size) ? (int) $size : Watermark::DEFAULT_SIZE);
115
-    }
116
-
117
-    /**
118
-     * Get the text to be watermarked for a certificate.
119
-     *
120
-     * @param ServerRequestInterface $request
121
-     * @param Certificate $certificate
122
-     * @return string
123
-     */
124
-    private function watermarkText(ServerRequestInterface $request, Certificate $certificate): string
125
-    {
126
-        $sid = Validator::queryParams($request)->isXref()->string('sid', '');
127
-        if ($sid !== '') {
128
-            $source = Registry::sourceFactory()->make($sid, $certificate->tree());
129
-        } else {
130
-            $source = $this->certif_data_service->oneLinkedSource($certificate);
131
-        }
132
-
133
-        if ($source !== null && $source->canShowName()) {
134
-            $repo = $source->facts(['REPO'])->first();
135
-            if ($repo !== null && ($repo = $repo->target()) !== null && $repo->canShowName()) {
136
-                return I18N::translate('© %s - %s', strip_tags($repo->fullName()), strip_tags($source->fullName()));
137
-            }
138
-            return strip_tags($source->fullName());
139
-        }
140
-        $default_text = $certificate->tree()->getPreference('MAJ_CERTIF_WM_DEFAULT');
141
-        return $default_text !== '' ? $default_text : I18N::translate('This image is protected under copyright law.');
142
-    }
41
+	private ?CertificatesModule $module;
42
+	private CertificateFilesystemService $certif_filesystem;
43
+	private CertificateImageFactory $certif_image_factory;
44
+	private CertificateDataService $certif_data_service;
45
+	private UrlObfuscatorService $url_obfuscator_service;
46
+
47
+	/**
48
+	 * Constructor for Certificate Image Request Handler
49
+	 *
50
+	 * @param ModuleService $module_service
51
+	 */
52
+	public function __construct(
53
+		ModuleService $module_service,
54
+		CertificateFilesystemService $certif_filesystem,
55
+		CertificateDataService $certif_data_service,
56
+		UrlObfuscatorService $url_obfuscator_service
57
+	) {
58
+		$this->module = $module_service->findByInterface(CertificatesModule::class)->first();
59
+		$this->certif_filesystem = $certif_filesystem;
60
+		$this->certif_image_factory = new CertificateImageFactory($this->certif_filesystem);
61
+		$this->certif_data_service = $certif_data_service;
62
+		$this->url_obfuscator_service = $url_obfuscator_service;
63
+	}
64
+
65
+	/**
66
+	 * {@inheritDoc}
67
+	 * @see \Psr\Http\Server\RequestHandlerInterface::handle()
68
+	 */
69
+	public function handle(ServerRequestInterface $request): ResponseInterface
70
+	{
71
+		if ($this->module === null) {
72
+			throw new HttpNotFoundException(I18N::translate('The attached module could not be found.'));
73
+		}
74
+
75
+		$tree = Validator::attributes($request)->tree();
76
+		$user = Validator::attributes($request)->user();
77
+
78
+		$certif_path = Validator::attributes($request)->string('cid', '');
79
+		$certificate = null;
80
+		if ($certif_path !== '' && $this->url_obfuscator_service->tryDeobfuscate($certif_path)) {
81
+			$certificate = $this->certif_filesystem->certificate($tree, $certif_path);
82
+		}
83
+
84
+		if ($certificate === null) {
85
+			return $this->certif_image_factory
86
+				->replacementImageResponse((string) StatusCodeInterface::STATUS_NOT_FOUND)
87
+				->withHeader('X-Image-Exception', I18N::translate('The certificate was not found in this family tree.'))
88
+			;
89
+		}
90
+
91
+		$use_watermark = $this->certif_image_factory->certificateNeedsWatermark($certificate, $user);
92
+		$watermark = $use_watermark ? $this->watermark($request, $certificate) : null;
93
+
94
+		return $this->certif_image_factory->certificateFileResponse(
95
+			$certificate,
96
+			$use_watermark,
97
+			$watermark
98
+		);
99
+	}
100
+
101
+	/**
102
+	 * Get watermark data for a certificate.
103
+	 *
104
+	 * @param ServerRequestInterface $request
105
+	 * @param Certificate $certificate
106
+	 * @return Watermark
107
+	 */
108
+	private function watermark(ServerRequestInterface $request, Certificate $certificate): Watermark
109
+	{
110
+		$color = $certificate->tree()->getPreference('MAJ_CERTIF_WM_FONT_COLOR', Watermark::DEFAULT_COLOR);
111
+		$size = $certificate->tree()->getPreference('MAJ_CERTIF_WM_FONT_MAXSIZE');
112
+		$text = $this->watermarkText($request, $certificate);
113
+
114
+		return new Watermark($text, $color, is_numeric($size) ? (int) $size : Watermark::DEFAULT_SIZE);
115
+	}
116
+
117
+	/**
118
+	 * Get the text to be watermarked for a certificate.
119
+	 *
120
+	 * @param ServerRequestInterface $request
121
+	 * @param Certificate $certificate
122
+	 * @return string
123
+	 */
124
+	private function watermarkText(ServerRequestInterface $request, Certificate $certificate): string
125
+	{
126
+		$sid = Validator::queryParams($request)->isXref()->string('sid', '');
127
+		if ($sid !== '') {
128
+			$source = Registry::sourceFactory()->make($sid, $certificate->tree());
129
+		} else {
130
+			$source = $this->certif_data_service->oneLinkedSource($certificate);
131
+		}
132
+
133
+		if ($source !== null && $source->canShowName()) {
134
+			$repo = $source->facts(['REPO'])->first();
135
+			if ($repo !== null && ($repo = $repo->target()) !== null && $repo->canShowName()) {
136
+				return I18N::translate('© %s - %s', strip_tags($repo->fullName()), strip_tags($source->fullName()));
137
+			}
138
+			return strip_tags($source->fullName());
139
+		}
140
+		$default_text = $certificate->tree()->getPreference('MAJ_CERTIF_WM_DEFAULT');
141
+		return $default_text !== '' ? $default_text : I18N::translate('This image is protected under copyright law.');
142
+	}
143 143
 }
Please login to merge, or discard this patch.
app/Module/Certificates/Http/RequestHandlers/CertificatesList.php 1 patch
Indentation   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -32,63 +32,63 @@
 block discarded – undo
32 32
  */
33 33
 class CertificatesList implements RequestHandlerInterface
34 34
 {
35
-    use ViewResponseTrait;
35
+	use ViewResponseTrait;
36 36
 
37
-    private ?CertificatesModule $module;
38
-    private CertificateFilesystemService $certif_filesystem;
39
-    private UrlObfuscatorService $url_obfuscator_service;
37
+	private ?CertificatesModule $module;
38
+	private CertificateFilesystemService $certif_filesystem;
39
+	private UrlObfuscatorService $url_obfuscator_service;
40 40
 
41
-    /**
42
-     * Constructor for CertificatesList Request Handler
43
-     *
44
-     * @param ModuleService $module_service
45
-     */
46
-    public function __construct(
47
-        ModuleService $module_service,
48
-        CertificateFilesystemService $certif_filesystem,
49
-        UrlObfuscatorService $url_obfuscator_service
50
-    ) {
51
-        $this->module = $module_service->findByInterface(CertificatesModule::class)->first();
52
-        $this->certif_filesystem = $certif_filesystem;
53
-        $this->url_obfuscator_service = $url_obfuscator_service;
54
-    }
41
+	/**
42
+	 * Constructor for CertificatesList Request Handler
43
+	 *
44
+	 * @param ModuleService $module_service
45
+	 */
46
+	public function __construct(
47
+		ModuleService $module_service,
48
+		CertificateFilesystemService $certif_filesystem,
49
+		UrlObfuscatorService $url_obfuscator_service
50
+	) {
51
+		$this->module = $module_service->findByInterface(CertificatesModule::class)->first();
52
+		$this->certif_filesystem = $certif_filesystem;
53
+		$this->url_obfuscator_service = $url_obfuscator_service;
54
+	}
55 55
 
56
-    /**
57
-     * {@inheritDoc}
58
-     * @see \Psr\Http\Server\RequestHandlerInterface::handle()
59
-     */
60
-    public function handle(ServerRequestInterface $request): ResponseInterface
61
-    {
62
-        if ($this->module === null) {
63
-            throw new HttpNotFoundException(I18N::translate('The attached module could not be found.'));
64
-        }
56
+	/**
57
+	 * {@inheritDoc}
58
+	 * @see \Psr\Http\Server\RequestHandlerInterface::handle()
59
+	 */
60
+	public function handle(ServerRequestInterface $request): ResponseInterface
61
+	{
62
+		if ($this->module === null) {
63
+			throw new HttpNotFoundException(I18N::translate('The attached module could not be found.'));
64
+		}
65 65
 
66
-        $tree = Validator::attributes($request)->tree();
66
+		$tree = Validator::attributes($request)->tree();
67 67
 
68
-        $title = I18N::translate('Certificates');
68
+		$title = I18N::translate('Certificates');
69 69
 
70
-        $cities = array_map(function (string $item): array {
71
-            return [$this->url_obfuscator_service->obfuscate($item), $item];
72
-        }, $this->certif_filesystem->cities($tree));
70
+		$cities = array_map(function (string $item): array {
71
+			return [$this->url_obfuscator_service->obfuscate($item), $item];
72
+		}, $this->certif_filesystem->cities($tree));
73 73
 
74
-        $city = Validator::queryParams($request)->string(
75
-            'cityobf',
76
-            Validator::attributes($request)->string('cityobf', '')
77
-        );
74
+		$city = Validator::queryParams($request)->string(
75
+			'cityobf',
76
+			Validator::attributes($request)->string('cityobf', '')
77
+		);
78 78
 
79
-        if ($city !== '' && $this->url_obfuscator_service->tryDeobfuscate($city)) {
80
-            $title = I18N::translate('Certificates for %s', $city);
81
-            $certificates = $this->certif_filesystem->certificatesForCity($tree, $city);
82
-        }
79
+		if ($city !== '' && $this->url_obfuscator_service->tryDeobfuscate($city)) {
80
+			$title = I18N::translate('Certificates for %s', $city);
81
+			$certificates = $this->certif_filesystem->certificatesForCity($tree, $city);
82
+		}
83 83
 
84
-        return $this->viewResponse($this->module->name() . '::certificates-list', [
85
-            'title'                     =>  $title,
86
-            'tree'                      =>  $tree,
87
-            'module_name'               =>  $this->module->name(),
88
-            'cities'                    =>  $cities,
89
-            'selected_city'             =>  $city,
90
-            'certificates_list'         =>  $certificates ?? collect(),
91
-            'url_obfuscator_service'    =>  $this->url_obfuscator_service
92
-        ]);
93
-    }
84
+		return $this->viewResponse($this->module->name() . '::certificates-list', [
85
+			'title'                     =>  $title,
86
+			'tree'                      =>  $tree,
87
+			'module_name'               =>  $this->module->name(),
88
+			'cities'                    =>  $cities,
89
+			'selected_city'             =>  $city,
90
+			'certificates_list'         =>  $certificates ?? collect(),
91
+			'url_obfuscator_service'    =>  $this->url_obfuscator_service
92
+		]);
93
+	}
94 94
 }
Please login to merge, or discard this patch.