Passed
Push — feature/code-analysis ( e321b8...2d8a51 )
by Jonathan
13:14 queued 09:07
created
app/Module/MiscExtensions/Http/RequestHandlers/AdminConfigPage.php 2 patches
Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -28,35 +28,35 @@
 block discarded – undo
28 28
  */
29 29
 class AdminConfigPage implements RequestHandlerInterface
30 30
 {
31
-    use ViewResponseTrait;
32
-
33
-    private ?MiscExtensionsModule $module;
34
-
35
-    /**
36
-     * Constructor for AdminConfigPage Request Handler
37
-     *
38
-     * @param ModuleService $module_service
39
-     */
40
-    public function __construct(ModuleService $module_service)
41
-    {
42
-        $this->module = $module_service->findByInterface(MiscExtensionsModule::class)->first();
43
-    }
44
-
45
-    /**
46
-     * {@inheritDoc}
47
-     * @see \Psr\Http\Server\RequestHandlerInterface::handle()
48
-     */
49
-    public function handle(ServerRequestInterface $request): ResponseInterface
50
-    {
51
-        $this->layout = 'layouts/administration';
52
-
53
-        if ($this->module === null) {
54
-            throw new HttpNotFoundException(I18N::translate('The attached module could not be found.'));
55
-        }
56
-
57
-        return $this->viewResponse($this->module->name() . '::admin/config', [
58
-            'module'    =>  $this->module,
59
-            'title'     =>  $this->module->title()
60
-        ]);
61
-    }
31
+	use ViewResponseTrait;
32
+
33
+	private ?MiscExtensionsModule $module;
34
+
35
+	/**
36
+	 * Constructor for AdminConfigPage Request Handler
37
+	 *
38
+	 * @param ModuleService $module_service
39
+	 */
40
+	public function __construct(ModuleService $module_service)
41
+	{
42
+		$this->module = $module_service->findByInterface(MiscExtensionsModule::class)->first();
43
+	}
44
+
45
+	/**
46
+	 * {@inheritDoc}
47
+	 * @see \Psr\Http\Server\RequestHandlerInterface::handle()
48
+	 */
49
+	public function handle(ServerRequestInterface $request): ResponseInterface
50
+	{
51
+		$this->layout = 'layouts/administration';
52
+
53
+		if ($this->module === null) {
54
+			throw new HttpNotFoundException(I18N::translate('The attached module could not be found.'));
55
+		}
56
+
57
+		return $this->viewResponse($this->module->name() . '::admin/config', [
58
+			'module'    =>  $this->module,
59
+			'title'     =>  $this->module->title()
60
+		]);
61
+	}
62 62
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@
 block discarded – undo
54 54
             throw new HttpNotFoundException(I18N::translate('The attached module could not be found.'));
55 55
         }
56 56
 
57
-        return $this->viewResponse($this->module->name() . '::admin/config', [
57
+        return $this->viewResponse($this->module->name().'::admin/config', [
58 58
             'module'    =>  $this->module,
59 59
             'title'     =>  $this->module->title()
60 60
         ]);
Please login to merge, or discard this patch.
app/Module/Sosa/Data/MissingAncestor.php 1 patch
Indentation   +67 added lines, -67 removed lines patch added patch discarded remove patch
@@ -21,79 +21,79 @@
 block discarded – undo
21 21
  */
22 22
 class MissingAncestor
23 23
 {
24
-    /**
25
-     * @var Individual $individual
26
-     */
27
-    private $individual;
24
+	/**
25
+	 * @var Individual $individual
26
+	 */
27
+	private $individual;
28 28
 
29
-    /**
30
-     * @var int $sosa
31
-     */
32
-    private $sosa;
29
+	/**
30
+	 * @var int $sosa
31
+	 */
32
+	private $sosa;
33 33
 
34
-    /**
35
-     * @var bool $missing_father
36
-     */
37
-    private $missing_father;
34
+	/**
35
+	 * @var bool $missing_father
36
+	 */
37
+	private $missing_father;
38 38
 
39
-    /**
40
-     * @var bool $missing_mother
41
-     */
42
-    private $missing_mother;
39
+	/**
40
+	 * @var bool $missing_mother
41
+	 */
42
+	private $missing_mother;
43 43
 
44
-    /**
45
-     * Constructor for MissingAncestor data class
46
-     *
47
-     * @param Individual $ancestor
48
-     * @param int $sosa
49
-     * @param bool $missing_father
50
-     * @param bool $missing_mother
51
-     */
52
-    public function __construct(Individual $ancestor, int $sosa, bool $missing_father, bool $missing_mother)
53
-    {
54
-        $this->individual = $ancestor;
55
-        $this->sosa = $sosa;
56
-        $this->missing_father = $missing_father;
57
-        $this->missing_mother = $missing_mother;
58
-    }
44
+	/**
45
+	 * Constructor for MissingAncestor data class
46
+	 *
47
+	 * @param Individual $ancestor
48
+	 * @param int $sosa
49
+	 * @param bool $missing_father
50
+	 * @param bool $missing_mother
51
+	 */
52
+	public function __construct(Individual $ancestor, int $sosa, bool $missing_father, bool $missing_mother)
53
+	{
54
+		$this->individual = $ancestor;
55
+		$this->sosa = $sosa;
56
+		$this->missing_father = $missing_father;
57
+		$this->missing_mother = $missing_mother;
58
+	}
59 59
 
60
-    /**
61
-     * Reference individual of the row
62
-     *
63
-     * @return Individual
64
-     */
65
-    public function individual(): Individual
66
-    {
67
-        return $this->individual;
68
-    }
60
+	/**
61
+	 * Reference individual of the row
62
+	 *
63
+	 * @return Individual
64
+	 */
65
+	public function individual(): Individual
66
+	{
67
+		return $this->individual;
68
+	}
69 69
 
70
-    /**
71
-     * Minimum sosa of the reference individual
72
-     *
73
-     * @return int
74
-     */
75
-    public function sosa(): int
76
-    {
77
-        return $this->sosa;
78
-    }
70
+	/**
71
+	 * Minimum sosa of the reference individual
72
+	 *
73
+	 * @return int
74
+	 */
75
+	public function sosa(): int
76
+	{
77
+		return $this->sosa;
78
+	}
79 79
 
80
-    /**
81
-     * Indicate whether the reference individual does not have a father
82
-     *
83
-     * @return bool
84
-     */
85
-    public function isFatherMissing(): bool
86
-    {
87
-        return $this->missing_father;
88
-    }
80
+	/**
81
+	 * Indicate whether the reference individual does not have a father
82
+	 *
83
+	 * @return bool
84
+	 */
85
+	public function isFatherMissing(): bool
86
+	{
87
+		return $this->missing_father;
88
+	}
89 89
 
90
-    /**
91
-     * Indicate whether the reference individual does not have a mother
92
-     *
93
-     * @return bool
94
-     */
95
-    public function isMotherMissing(): bool
96
-    {
97
-        return $this->missing_mother;
98
-    }
90
+	/**
91
+	 * Indicate whether the reference individual does not have a mother
92
+	 *
93
+	 * @return bool
94
+	 */
95
+	public function isMotherMissing(): bool
96
+	{
97
+		return $this->missing_mother;
98
+	}
99 99
 }
Please login to merge, or discard this patch.
app/Module/Sosa/Http/RequestHandlers/SosaStatistics.php 2 patches
Spacing   +14 added lines, -17 removed lines patch added patch discarded remove patch
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
         /** @var SosaStatisticsService $sosa_stats_service */
72 72
         $sosa_stats_service = app()->makeWith(SosaStatisticsService::class, ['tree' => $tree, 'user' => $user]);
73 73
 
74
-        return $this->viewResponse($this->module->name() . '::statistics-page', [
74
+        return $this->viewResponse($this->module->name().'::statistics-page', [
75 75
             'module_name'       =>  $this->module->name(),
76 76
             'title'             =>  I18N::translate('Sosa Statistics'),
77 77
             'tree'              =>  $tree,
@@ -126,37 +126,34 @@  discard block
 block discarded – undo
126 126
 
127 127
         foreach ($stats_by_gen as $gen => $stats_gen) {
128 128
             $gen_diff = $gen > 1 ?
129
-                (int) $stats_gen['diffSosaTotalCount'] - (int) $stats_by_gen[$gen - 1]['diffSosaTotalCount'] :
130
-                1;
129
+                (int)$stats_gen['diffSosaTotalCount'] - (int)$stats_by_gen[$gen - 1]['diffSosaTotalCount'] : 1;
131 130
             $generation_stats[$gen] = array(
132
-                'gen_min_birth' => $stats_gen['firstBirth'] ?? (int) $stats_gen['firstEstimatedBirth'],
133
-                'gen_max_birth' => $stats_gen['lastBirth'] ?? (int) $stats_gen['lastEstimatedBirth'],
131
+                'gen_min_birth' => $stats_gen['firstBirth'] ?? (int)$stats_gen['firstEstimatedBirth'],
132
+                'gen_max_birth' => $stats_gen['lastBirth'] ?? (int)$stats_gen['lastEstimatedBirth'],
134 133
                 'theoretical' => BigInteger::of(2)->power($gen - 1)->toInt(),
135
-                'known' => (int) $stats_gen['sosaCount'],
134
+                'known' => (int)$stats_gen['sosaCount'],
136 135
                 'perc_known' => $this->safeDivision(
137
-                    BigInteger::of((int) $stats_gen['sosaCount']),
136
+                    BigInteger::of((int)$stats_gen['sosaCount']),
138 137
                     BigInteger::of(2)->power($gen - 1)
139 138
                 ),
140 139
                 'missing' => $gen > 1 ?
141
-                    2 * (int) $stats_by_gen[$gen - 1]['sosaCount'] - (int) $stats_gen['sosaCount'] :
142
-                    0,
140
+                    2 * (int)$stats_by_gen[$gen - 1]['sosaCount'] - (int)$stats_gen['sosaCount'] : 0,
143 141
                 'perc_missing' => $gen > 1 ?
144 142
                     1 - $this->safeDivision(
145
-                        BigInteger::of((int) $stats_gen['sosaCount']),
146
-                        BigInteger::of(2 * (int) $stats_by_gen[$gen - 1]['sosaCount'])
147
-                    ) :
148
-                    0,
149
-                'total_known' => (int) $stats_gen['sosaTotalCount'],
143
+                        BigInteger::of((int)$stats_gen['sosaCount']),
144
+                        BigInteger::of(2 * (int)$stats_by_gen[$gen - 1]['sosaCount'])
145
+                    ) : 0,
146
+                'total_known' => (int)$stats_gen['sosaTotalCount'],
150 147
                 'perc_total_known' => $this->safeDivision(
151
-                    BigInteger::of((int) $stats_gen['sosaTotalCount']),
148
+                    BigInteger::of((int)$stats_gen['sosaTotalCount']),
152 149
                     BigInteger::of(2)->power($gen)->minus(1)
153 150
                 ),
154 151
                 'different' => $gen_diff,
155 152
                 'perc_different' => $this->safeDivision(
156 153
                     BigInteger::of($gen_diff),
157
-                    BigInteger::of((int) $stats_gen['sosaCount'])
154
+                    BigInteger::of((int)$stats_gen['sosaCount'])
158 155
                 ),
159
-                'total_different' => (int) $stats_gen['diffSosaTotalCount']
156
+                'total_different' => (int)$stats_gen['diffSosaTotalCount']
160 157
             );
161 158
         }
162 159
 
Please login to merge, or discard this patch.
Indentation   +138 added lines, -138 removed lines patch added patch discarded remove patch
@@ -38,142 +38,142 @@
 block discarded – undo
38 38
  */
39 39
 class SosaStatistics implements RequestHandlerInterface
40 40
 {
41
-    use ViewResponseTrait;
42
-
43
-    private ?SosaModule $module;
44
-    private RelationshipService $relationship_service;
45
-
46
-    /**
47
-     * Constructor for AncestorsList Request Handler
48
-     *
49
-     * @param ModuleService $module_service
50
-     */
51
-    public function __construct(ModuleService $module_service, RelationshipService $relationship_service)
52
-    {
53
-        $this->module = $module_service->findByInterface(SosaModule::class)->first();
54
-        $this->relationship_service = $relationship_service;
55
-    }
56
-
57
-    /**
58
-     * {@inheritDoc}
59
-     * @see \Psr\Http\Server\RequestHandlerInterface::handle()
60
-     */
61
-    public function handle(ServerRequestInterface $request): ResponseInterface
62
-    {
63
-        if ($this->module === null) {
64
-            throw new HttpNotFoundException(I18N::translate('The attached module could not be found.'));
65
-        }
66
-
67
-        $tree = Validator::attributes($request)->tree();
68
-        $user = Auth::check() ? Validator::attributes($request)->user() : new DefaultUser();
69
-
70
-        /** @var SosaStatisticsService $sosa_stats_service */
71
-        $sosa_stats_service = app()->makeWith(SosaStatisticsService::class, ['tree' => $tree, 'user' => $user]);
72
-
73
-        return $this->viewResponse($this->module->name() . '::statistics-page', [
74
-            'module_name'       =>  $this->module->name(),
75
-            'title'             =>  I18N::translate('Sosa Statistics'),
76
-            'tree'              =>  $tree,
77
-            'theme'             =>  app(ModuleThemeInterface::class),
78
-            'root_indi'         =>  $sosa_stats_service->rootIndividual(),
79
-            'general_stats'     =>  $this->statisticsGeneral($sosa_stats_service),
80
-            'generation_stats'  =>  $this->statisticsByGenerations($sosa_stats_service),
81
-            'generation_depth'  =>  $sosa_stats_service->generationDepthStatsAtGeneration(1)->first(),
82
-            'multiple_sosas'    =>  $sosa_stats_service->topMultipleAncestorsWithNoTies(10)->groupBy('sosa_count'),
83
-            'sosa_dispersion_g2' =>  $sosa_stats_service->ancestorsDispersionForGeneration(2),
84
-            'sosa_dispersion_g3' =>  $sosa_stats_service->ancestorsDispersionForGeneration(3),
85
-            'gen_depth_g3'      =>  $sosa_stats_service->generationDepthStatsAtGeneration(3),
86
-            'relationship_service'  =>  $this->relationship_service,
87
-        ]);
88
-    }
89
-
90
-    /**
91
-     * Retrieve and compute the global statistics of ancestors for the tree.
92
-     * Statistics include the number of ancestors, the number of different ancestors, pedigree collapse...
93
-     *
94
-     * @param SosaStatisticsService $sosa_stats_service
95
-     * @return array<string, int|float>
96
-     */
97
-    private function statisticsGeneral(SosaStatisticsService $sosa_stats_service): array
98
-    {
99
-        $ancestors_count = $sosa_stats_service->totalAncestors();
100
-        $ancestors_distinct_count = $sosa_stats_service->totalDistinctAncestors();
101
-        $individual_count = $sosa_stats_service->totalIndividuals();
102
-
103
-        return [
104
-            'sosa_count'    =>  $ancestors_count,
105
-            'distinct_count'    =>  $ancestors_distinct_count,
106
-            'sosa_rate' =>  $this->safeDivision(
107
-                BigInteger::of($ancestors_distinct_count),
108
-                BigInteger::of($individual_count)
109
-            ),
110
-            'mean_gen_time'         =>  $sosa_stats_service->meanGenerationTime()
111
-        ];
112
-    }
113
-
114
-    /**
115
-     * Retrieve and compute the statistics of ancestors by generations.
116
-     * Statistics include the number of ancestors, the number of different ancestors, cumulative statistics...
117
-     *
118
-     * @param SosaStatisticsService $sosa_stats_service
119
-     * @return array<int, array<string, int|float>>
120
-     */
121
-    private function statisticsByGenerations(SosaStatisticsService $sosa_stats_service): array
122
-    {
123
-        $stats_by_gen = $sosa_stats_service->statisticsByGenerations();
124
-
125
-        $generation_stats = array();
126
-
127
-        foreach ($stats_by_gen as $gen => $stats_gen) {
128
-            $gen_diff = $gen > 1 ?
129
-                (int) $stats_gen['diffSosaTotalCount'] - (int) $stats_by_gen[$gen - 1]['diffSosaTotalCount'] :
130
-                1;
131
-            $generation_stats[$gen] = array(
132
-                'gen_min_birth' => $stats_gen['firstBirth'] ?? (int) $stats_gen['firstEstimatedBirth'],
133
-                'gen_max_birth' => $stats_gen['lastBirth'] ?? (int) $stats_gen['lastEstimatedBirth'],
134
-                'theoretical' => BigInteger::of(2)->power($gen - 1)->toInt(),
135
-                'known' => (int) $stats_gen['sosaCount'],
136
-                'perc_known' => $this->safeDivision(
137
-                    BigInteger::of((int) $stats_gen['sosaCount']),
138
-                    BigInteger::of(2)->power($gen - 1)
139
-                ),
140
-                'missing' => $gen > 1 ?
141
-                    2 * (int) $stats_by_gen[$gen - 1]['sosaCount'] - (int) $stats_gen['sosaCount'] :
142
-                    0,
143
-                'perc_missing' => $gen > 1 ?
144
-                    1 - $this->safeDivision(
145
-                        BigInteger::of((int) $stats_gen['sosaCount']),
146
-                        BigInteger::of(2 * (int) $stats_by_gen[$gen - 1]['sosaCount'])
147
-                    ) :
148
-                    0,
149
-                'total_known' => (int) $stats_gen['sosaTotalCount'],
150
-                'perc_total_known' => $this->safeDivision(
151
-                    BigInteger::of((int) $stats_gen['sosaTotalCount']),
152
-                    BigInteger::of(2)->power($gen)->minus(1)
153
-                ),
154
-                'different' => $gen_diff,
155
-                'perc_different' => $this->safeDivision(
156
-                    BigInteger::of($gen_diff),
157
-                    BigInteger::of((int) $stats_gen['sosaCount'])
158
-                ),
159
-                'total_different' => (int) $stats_gen['diffSosaTotalCount']
160
-            );
161
-        }
162
-
163
-        return $generation_stats;
164
-    }
165
-
166
-    /**
167
-     * Return the result of a division, and a default value if denominator is 0
168
-     *
169
-     * @param BigInteger $p Numerator
170
-     * @param BigInteger $q Denominator
171
-     * @param int $scale Rounding scale
172
-     * @param float $default Value if denominator is 0
173
-     * @return float
174
-     */
175
-    private function safeDivision(BigInteger $p, BigInteger $q, int $scale = 10, float $default = 0): float
176
-    {
177
-        return $q->isZero() ? $default : $p->toBigDecimal()->dividedBy($q, $scale, RoundingMode::HALF_DOWN)->toFloat();
178
-    }
41
+	use ViewResponseTrait;
42
+
43
+	private ?SosaModule $module;
44
+	private RelationshipService $relationship_service;
45
+
46
+	/**
47
+	 * Constructor for AncestorsList Request Handler
48
+	 *
49
+	 * @param ModuleService $module_service
50
+	 */
51
+	public function __construct(ModuleService $module_service, RelationshipService $relationship_service)
52
+	{
53
+		$this->module = $module_service->findByInterface(SosaModule::class)->first();
54
+		$this->relationship_service = $relationship_service;
55
+	}
56
+
57
+	/**
58
+	 * {@inheritDoc}
59
+	 * @see \Psr\Http\Server\RequestHandlerInterface::handle()
60
+	 */
61
+	public function handle(ServerRequestInterface $request): ResponseInterface
62
+	{
63
+		if ($this->module === null) {
64
+			throw new HttpNotFoundException(I18N::translate('The attached module could not be found.'));
65
+		}
66
+
67
+		$tree = Validator::attributes($request)->tree();
68
+		$user = Auth::check() ? Validator::attributes($request)->user() : new DefaultUser();
69
+
70
+		/** @var SosaStatisticsService $sosa_stats_service */
71
+		$sosa_stats_service = app()->makeWith(SosaStatisticsService::class, ['tree' => $tree, 'user' => $user]);
72
+
73
+		return $this->viewResponse($this->module->name() . '::statistics-page', [
74
+			'module_name'       =>  $this->module->name(),
75
+			'title'             =>  I18N::translate('Sosa Statistics'),
76
+			'tree'              =>  $tree,
77
+			'theme'             =>  app(ModuleThemeInterface::class),
78
+			'root_indi'         =>  $sosa_stats_service->rootIndividual(),
79
+			'general_stats'     =>  $this->statisticsGeneral($sosa_stats_service),
80
+			'generation_stats'  =>  $this->statisticsByGenerations($sosa_stats_service),
81
+			'generation_depth'  =>  $sosa_stats_service->generationDepthStatsAtGeneration(1)->first(),
82
+			'multiple_sosas'    =>  $sosa_stats_service->topMultipleAncestorsWithNoTies(10)->groupBy('sosa_count'),
83
+			'sosa_dispersion_g2' =>  $sosa_stats_service->ancestorsDispersionForGeneration(2),
84
+			'sosa_dispersion_g3' =>  $sosa_stats_service->ancestorsDispersionForGeneration(3),
85
+			'gen_depth_g3'      =>  $sosa_stats_service->generationDepthStatsAtGeneration(3),
86
+			'relationship_service'  =>  $this->relationship_service,
87
+		]);
88
+	}
89
+
90
+	/**
91
+	 * Retrieve and compute the global statistics of ancestors for the tree.
92
+	 * Statistics include the number of ancestors, the number of different ancestors, pedigree collapse...
93
+	 *
94
+	 * @param SosaStatisticsService $sosa_stats_service
95
+	 * @return array<string, int|float>
96
+	 */
97
+	private function statisticsGeneral(SosaStatisticsService $sosa_stats_service): array
98
+	{
99
+		$ancestors_count = $sosa_stats_service->totalAncestors();
100
+		$ancestors_distinct_count = $sosa_stats_service->totalDistinctAncestors();
101
+		$individual_count = $sosa_stats_service->totalIndividuals();
102
+
103
+		return [
104
+			'sosa_count'    =>  $ancestors_count,
105
+			'distinct_count'    =>  $ancestors_distinct_count,
106
+			'sosa_rate' =>  $this->safeDivision(
107
+				BigInteger::of($ancestors_distinct_count),
108
+				BigInteger::of($individual_count)
109
+			),
110
+			'mean_gen_time'         =>  $sosa_stats_service->meanGenerationTime()
111
+		];
112
+	}
113
+
114
+	/**
115
+	 * Retrieve and compute the statistics of ancestors by generations.
116
+	 * Statistics include the number of ancestors, the number of different ancestors, cumulative statistics...
117
+	 *
118
+	 * @param SosaStatisticsService $sosa_stats_service
119
+	 * @return array<int, array<string, int|float>>
120
+	 */
121
+	private function statisticsByGenerations(SosaStatisticsService $sosa_stats_service): array
122
+	{
123
+		$stats_by_gen = $sosa_stats_service->statisticsByGenerations();
124
+
125
+		$generation_stats = array();
126
+
127
+		foreach ($stats_by_gen as $gen => $stats_gen) {
128
+			$gen_diff = $gen > 1 ?
129
+				(int) $stats_gen['diffSosaTotalCount'] - (int) $stats_by_gen[$gen - 1]['diffSosaTotalCount'] :
130
+				1;
131
+			$generation_stats[$gen] = array(
132
+				'gen_min_birth' => $stats_gen['firstBirth'] ?? (int) $stats_gen['firstEstimatedBirth'],
133
+				'gen_max_birth' => $stats_gen['lastBirth'] ?? (int) $stats_gen['lastEstimatedBirth'],
134
+				'theoretical' => BigInteger::of(2)->power($gen - 1)->toInt(),
135
+				'known' => (int) $stats_gen['sosaCount'],
136
+				'perc_known' => $this->safeDivision(
137
+					BigInteger::of((int) $stats_gen['sosaCount']),
138
+					BigInteger::of(2)->power($gen - 1)
139
+				),
140
+				'missing' => $gen > 1 ?
141
+					2 * (int) $stats_by_gen[$gen - 1]['sosaCount'] - (int) $stats_gen['sosaCount'] :
142
+					0,
143
+				'perc_missing' => $gen > 1 ?
144
+					1 - $this->safeDivision(
145
+						BigInteger::of((int) $stats_gen['sosaCount']),
146
+						BigInteger::of(2 * (int) $stats_by_gen[$gen - 1]['sosaCount'])
147
+					) :
148
+					0,
149
+				'total_known' => (int) $stats_gen['sosaTotalCount'],
150
+				'perc_total_known' => $this->safeDivision(
151
+					BigInteger::of((int) $stats_gen['sosaTotalCount']),
152
+					BigInteger::of(2)->power($gen)->minus(1)
153
+				),
154
+				'different' => $gen_diff,
155
+				'perc_different' => $this->safeDivision(
156
+					BigInteger::of($gen_diff),
157
+					BigInteger::of((int) $stats_gen['sosaCount'])
158
+				),
159
+				'total_different' => (int) $stats_gen['diffSosaTotalCount']
160
+			);
161
+		}
162
+
163
+		return $generation_stats;
164
+	}
165
+
166
+	/**
167
+	 * Return the result of a division, and a default value if denominator is 0
168
+	 *
169
+	 * @param BigInteger $p Numerator
170
+	 * @param BigInteger $q Denominator
171
+	 * @param int $scale Rounding scale
172
+	 * @param float $default Value if denominator is 0
173
+	 * @return float
174
+	 */
175
+	private function safeDivision(BigInteger $p, BigInteger $q, int $scale = 10, float $default = 0): float
176
+	{
177
+		return $q->isZero() ? $default : $p->toBigDecimal()->dividedBy($q, $scale, RoundingMode::HALF_DOWN)->toFloat();
178
+	}
179 179
 }
Please login to merge, or discard this patch.
app/Module/Sosa/Http/RequestHandlers/PedigreeCollapseData.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -67,10 +67,10 @@
 block discarded – undo
67 67
         $sosa_stats_service = app()->makeWith(SosaStatisticsService::class, ['tree' => $tree, 'user' => $user]);
68 68
         $pedi_collapse_data = $sosa_stats_service->pedigreeCollapseByGenerationData();
69 69
 
70
-        $response = [ 'cells' => [] ];
70
+        $response = ['cells' => []];
71 71
         $last_pedi_collapse = 0;
72 72
         foreach ($pedi_collapse_data as $gen => $rec) {
73
-            $response['cells'][$gen] = view($this->module->name() . '::components/pedigree-collapse-cell', [
73
+            $response['cells'][$gen] = view($this->module->name().'::components/pedigree-collapse-cell', [
74 74
                 'pedi_collapse_roots'   =>  $rec['pedi_collapse_roots'],
75 75
                 'pedi_collapse_xgen'    =>  $rec['pedi_collapse_xgen']
76 76
             ]);
Please login to merge, or discard this patch.
Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -33,49 +33,49 @@
 block discarded – undo
33 33
  */
34 34
 class PedigreeCollapseData implements RequestHandlerInterface
35 35
 {
36
-    /**
37
-     * @var SosaModule|null $module
38
-     */
39
-    private $module;
36
+	/**
37
+	 * @var SosaModule|null $module
38
+	 */
39
+	private $module;
40 40
 
41
-    /**
42
-     * Constructor for PedigreeCollapseData Request Handler
43
-     *
44
-     * @param ModuleService $module_service
45
-     */
46
-    public function __construct(ModuleService $module_service)
47
-    {
48
-        $this->module = $module_service->findByInterface(SosaModule::class)->first();
49
-    }
41
+	/**
42
+	 * Constructor for PedigreeCollapseData Request Handler
43
+	 *
44
+	 * @param ModuleService $module_service
45
+	 */
46
+	public function __construct(ModuleService $module_service)
47
+	{
48
+		$this->module = $module_service->findByInterface(SosaModule::class)->first();
49
+	}
50 50
 
51
-    /**
52
-     * {@inheritDoc}
53
-     * @see \Psr\Http\Server\RequestHandlerInterface::handle()
54
-     */
55
-    public function handle(ServerRequestInterface $request): ResponseInterface
56
-    {
57
-        if ($this->module === null) {
58
-            throw new HttpNotFoundException(I18N::translate('The attached module could not be found.'));
59
-        }
51
+	/**
52
+	 * {@inheritDoc}
53
+	 * @see \Psr\Http\Server\RequestHandlerInterface::handle()
54
+	 */
55
+	public function handle(ServerRequestInterface $request): ResponseInterface
56
+	{
57
+		if ($this->module === null) {
58
+			throw new HttpNotFoundException(I18N::translate('The attached module could not be found.'));
59
+		}
60 60
 
61
-        $tree = Validator::attributes($request)->tree();
62
-        $user = Auth::check() ? Validator::attributes($request)->user() : new DefaultUser();
61
+		$tree = Validator::attributes($request)->tree();
62
+		$user = Auth::check() ? Validator::attributes($request)->user() : new DefaultUser();
63 63
 
64
-        /** @var SosaStatisticsService $sosa_stats_service */
65
-        $sosa_stats_service = app()->makeWith(SosaStatisticsService::class, ['tree' => $tree, 'user' => $user]);
66
-        $pedi_collapse_data = $sosa_stats_service->pedigreeCollapseByGenerationData();
64
+		/** @var SosaStatisticsService $sosa_stats_service */
65
+		$sosa_stats_service = app()->makeWith(SosaStatisticsService::class, ['tree' => $tree, 'user' => $user]);
66
+		$pedi_collapse_data = $sosa_stats_service->pedigreeCollapseByGenerationData();
67 67
 
68
-        $response = [ 'cells' => [] ];
69
-        $last_pedi_collapse = 0;
70
-        foreach ($pedi_collapse_data as $gen => $rec) {
71
-            $response['cells'][$gen] = view($this->module->name() . '::components/pedigree-collapse-cell', [
72
-                'pedi_collapse_roots'   =>  $rec['pedi_collapse_roots'],
73
-                'pedi_collapse_xgen'    =>  $rec['pedi_collapse_xgen']
74
-            ]);
75
-            $last_pedi_collapse = $rec['pedi_collapse_roots'];
76
-        }
77
-        $response['pedi_collapse'] = I18N::percentage($last_pedi_collapse, 2);
68
+		$response = [ 'cells' => [] ];
69
+		$last_pedi_collapse = 0;
70
+		foreach ($pedi_collapse_data as $gen => $rec) {
71
+			$response['cells'][$gen] = view($this->module->name() . '::components/pedigree-collapse-cell', [
72
+				'pedi_collapse_roots'   =>  $rec['pedi_collapse_roots'],
73
+				'pedi_collapse_xgen'    =>  $rec['pedi_collapse_xgen']
74
+			]);
75
+			$last_pedi_collapse = $rec['pedi_collapse_roots'];
76
+		}
77
+		$response['pedi_collapse'] = I18N::percentage($last_pedi_collapse, 2);
78 78
 
79
-        return Registry::responseFactory()->response($response);
80
-    }
79
+		return Registry::responseFactory()->response($response);
80
+	}
81 81
 }
Please login to merge, or discard this patch.
app/Module/Sosa/Schema/Migration2.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@
 block discarded – undo
34 34
         // Clean up previous sosa table if it exists
35 35
         DB::schema()->dropIfExists('maj_sosa');
36 36
 
37
-        DB::schema()->create('maj_sosa', static function (Blueprint $table): void {
37
+        DB::schema()->create('maj_sosa', static function(Blueprint $table): void {
38 38
 
39 39
             $table->integer('majs_gedcom_id');
40 40
             $table->integer('majs_user_id')->default(-1);
Please login to merge, or discard this patch.
Indentation   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -23,41 +23,41 @@
 block discarded – undo
23 23
  */
24 24
 class Migration2 implements MigrationInterface
25 25
 {
26
-    /**
27
-     * {@inheritDoc}
28
-     * @see \Fisharebest\Webtrees\Schema\MigrationInterface::upgrade()
29
-     */
30
-    public function upgrade(): void
31
-    {
32
-        $in_transaction = DB::connection()->getPdo()->inTransaction();
33
-
34
-        // Clean up previous sosa table if it exists
35
-        DB::schema()->dropIfExists('maj_sosa');
36
-
37
-        DB::schema()->create('maj_sosa', static function (Blueprint $table): void {
38
-
39
-            $table->integer('majs_gedcom_id');
40
-            $table->integer('majs_user_id')->default(-1);
41
-            $table->bigInteger('majs_sosa')->unsigned(); // Allow to calculate sosa on 64 generations
42
-            $table->string('majs_i_id', 20);
43
-            $table->tinyInteger('majs_gen')->nullable();
44
-            $table->smallInteger('majs_birth_year')->nullable();
45
-            $table->smallInteger('majs_birth_year_est')->nullable();
46
-            $table->smallInteger('majs_death_year')->nullable();
47
-            $table->smallInteger('majs_death_year_est')->nullable();
48
-
49
-            $table->primary(['majs_gedcom_id', 'majs_user_id', 'majs_sosa']);
50
-
51
-            $table->index(['majs_gedcom_id', 'majs_user_id']);
52
-            $table->index(['majs_gedcom_id', 'majs_user_id', 'majs_i_id']);
53
-            $table->index(['majs_gedcom_id', 'majs_user_id', 'majs_gen']);
54
-
55
-            $table->foreign('majs_gedcom_id')->references('gedcom_id')->on('gedcom')->onDelete('cascade');
56
-            $table->foreign('majs_user_id')->references('user_id')->on('user')->onDelete('cascade');
57
-        });
58
-
59
-        if ($in_transaction && !DB::connection()->getPdo()->inTransaction()) {
60
-            DB::connection()->beginTransaction();
61
-        }
62
-    }
26
+	/**
27
+	 * {@inheritDoc}
28
+	 * @see \Fisharebest\Webtrees\Schema\MigrationInterface::upgrade()
29
+	 */
30
+	public function upgrade(): void
31
+	{
32
+		$in_transaction = DB::connection()->getPdo()->inTransaction();
33
+
34
+		// Clean up previous sosa table if it exists
35
+		DB::schema()->dropIfExists('maj_sosa');
36
+
37
+		DB::schema()->create('maj_sosa', static function (Blueprint $table): void {
38
+
39
+			$table->integer('majs_gedcom_id');
40
+			$table->integer('majs_user_id')->default(-1);
41
+			$table->bigInteger('majs_sosa')->unsigned(); // Allow to calculate sosa on 64 generations
42
+			$table->string('majs_i_id', 20);
43
+			$table->tinyInteger('majs_gen')->nullable();
44
+			$table->smallInteger('majs_birth_year')->nullable();
45
+			$table->smallInteger('majs_birth_year_est')->nullable();
46
+			$table->smallInteger('majs_death_year')->nullable();
47
+			$table->smallInteger('majs_death_year_est')->nullable();
48
+
49
+			$table->primary(['majs_gedcom_id', 'majs_user_id', 'majs_sosa']);
50
+
51
+			$table->index(['majs_gedcom_id', 'majs_user_id']);
52
+			$table->index(['majs_gedcom_id', 'majs_user_id', 'majs_i_id']);
53
+			$table->index(['majs_gedcom_id', 'majs_user_id', 'majs_gen']);
54
+
55
+			$table->foreign('majs_gedcom_id')->references('gedcom_id')->on('gedcom')->onDelete('cascade');
56
+			$table->foreign('majs_user_id')->references('user_id')->on('user')->onDelete('cascade');
57
+		});
58
+
59
+		if ($in_transaction && !DB::connection()->getPdo()->inTransaction()) {
60
+			DB::connection()->beginTransaction();
61
+		}
62
+	}
63 63
 }
Please login to merge, or discard this patch.
app/Module/Sosa/Services/SosaCalculatorService.php 2 patches
Indentation   +139 added lines, -139 removed lines patch added patch discarded remove patch
@@ -24,143 +24,143 @@
 block discarded – undo
24 24
  */
25 25
 class SosaCalculatorService
26 26
 {
27
-    /**
28
-     * Maximium size for the temporary Sosa table
29
-     * @var int TMP_SOSA_TABLE_LIMIT
30
-     */
31
-    private const TMP_SOSA_TABLE_LIMIT = 1000;
32
-
33
-    /**
34
-     * @var SosaRecordsService $sosa_records_service
35
-     */
36
-    private $sosa_records_service;
37
-
38
-    /**
39
-     * Reference user
40
-     * @var UserInterface $user
41
-     */
42
-    private $user;
43
-
44
-    /**
45
-     * Reference tree
46
-     * @var Tree $tree
47
-     */
48
-    private $tree;
49
-
50
-    /**
51
-     * Temporary Sosa table, used during construction
52
-     * @var array<array<string,mixed>> $tmp_sosa_table
53
-     */
54
-    private $tmp_sosa_table;
55
-
56
-    /**
57
-     * Maximum number of generations to calculate
58
-     * @var int $max_generations
59
-     */
60
-    private $max_generations;
61
-
62
-    /**
63
-     * Constructor for the Sosa Calculator
64
-     *
65
-     * @param SosaRecordsService $sosa_records_service
66
-     * @param Tree $tree
67
-     * @param UserInterface $user
68
-     */
69
-    public function __construct(SosaRecordsService $sosa_records_service, Tree $tree, UserInterface $user)
70
-    {
71
-        $this->sosa_records_service = $sosa_records_service;
72
-        $this->tree = $tree;
73
-        $this->user = $user;
74
-        $this->tmp_sosa_table = array();
75
-        $max_gen_setting = $tree->getUserPreference($user, 'MAJ_SOSA_MAX_GEN');
76
-        $this->max_generations = is_numeric($max_gen_setting) ?
77
-            (int) $max_gen_setting :
78
-            $this->sosa_records_service->maxSystemGenerations();
79
-    }
80
-
81
-    /**
82
-     * Compute all Sosa ancestors from the user's root individual.
83
-     *
84
-     * @return bool Result of the computation
85
-     */
86
-    public function computeAll(): bool
87
-    {
88
-        $root_id = $this->tree->getUserPreference($this->user, 'MAJ_SOSA_ROOT_ID');
89
-        if (($indi = Registry::individualFactory()->make($root_id, $this->tree)) !== null) {
90
-            $this->sosa_records_service->deleteAll($this->tree, $this->user);
91
-            $this->addNode($indi, 1);
92
-            $this->flushTmpSosaTable(true);
93
-            return true;
94
-        }
95
-        return false;
96
-    }
97
-
98
-    /**
99
-     * Compute all Sosa Ancestors from a specified Individual
100
-     *
101
-     * @param Individual $indi
102
-     * @return bool
103
-     */
104
-    public function computeFromIndividual(Individual $indi): bool
105
-    {
106
-        $current_sosas = $this->sosa_records_service->sosaNumbers($this->tree, $this->user, $indi);
107
-        foreach ($current_sosas->keys() as $sosa) {
108
-            $this->sosa_records_service->deleteAncestorsFrom($this->tree, $this->user, $sosa);
109
-            $this->addNode($indi, $sosa);
110
-        }
111
-        $this->flushTmpSosaTable(true);
112
-        return true;
113
-    }
114
-
115
-    /**
116
-     * Recursive method to add individual to the Sosa table, and flush it regularly
117
-     *
118
-     * @param Individual $indi Individual to add
119
-     * @param int $sosa Individual's sosa
120
-     */
121
-    private function addNode(Individual $indi, int $sosa): void
122
-    {
123
-        $birth_year = $indi->getBirthDate()->gregorianYear();
124
-        $birth_year_est = $birth_year === 0 ? $indi->getEstimatedBirthDate()->gregorianYear() : $birth_year;
125
-
126
-        $death_year = $indi->getDeathDate()->gregorianYear();
127
-        $death_year_est = $death_year === 0 ? $indi->getEstimatedDeathDate()->gregorianYear() : $death_year;
128
-
129
-        $this->tmp_sosa_table[] = [
130
-            'indi' => $indi->xref(),
131
-            'sosa' => $sosa,
132
-            'birth_year' => $birth_year === 0 ? null : $birth_year,
133
-            'birth_year_est' => $birth_year_est === 0 ? null : $birth_year_est,
134
-            'death_year' => $death_year === 0 ? null : $death_year,
135
-            'death_year_est' => $death_year_est === 0 ? null : $death_year_est
136
-        ];
137
-
138
-        $this->flushTmpSosaTable();
139
-
140
-        if (
141
-            ($fam = $indi->childFamilies()->first()) !== null
142
-            && $this->sosa_records_service->generation($sosa) < $this->max_generations
143
-        ) {
144
-            /** @var \Fisharebest\Webtrees\Family $fam */
145
-            if (($husb = $fam->husband()) !== null) {
146
-                $this->addNode($husb, 2 * $sosa);
147
-            }
148
-            if (($wife = $fam->wife()) !== null) {
149
-                $this->addNode($wife, 2 * $sosa + 1);
150
-            }
151
-        }
152
-    }
153
-
154
-    /**
155
-     * Write sosas in the table, if the number of items is superior to the limit, or if forced.
156
-     *
157
-     * @param bool $force Should the flush be forced
158
-     */
159
-    private function flushTmpSosaTable($force = false): void
160
-    {
161
-        if ($force || count($this->tmp_sosa_table) >= self::TMP_SOSA_TABLE_LIMIT) {
162
-            $this->sosa_records_service->insertOrUpdate($this->tree, $this->user, $this->tmp_sosa_table);
163
-            $this->tmp_sosa_table = array();
164
-        }
165
-    }
27
+	/**
28
+	 * Maximium size for the temporary Sosa table
29
+	 * @var int TMP_SOSA_TABLE_LIMIT
30
+	 */
31
+	private const TMP_SOSA_TABLE_LIMIT = 1000;
32
+
33
+	/**
34
+	 * @var SosaRecordsService $sosa_records_service
35
+	 */
36
+	private $sosa_records_service;
37
+
38
+	/**
39
+	 * Reference user
40
+	 * @var UserInterface $user
41
+	 */
42
+	private $user;
43
+
44
+	/**
45
+	 * Reference tree
46
+	 * @var Tree $tree
47
+	 */
48
+	private $tree;
49
+
50
+	/**
51
+	 * Temporary Sosa table, used during construction
52
+	 * @var array<array<string,mixed>> $tmp_sosa_table
53
+	 */
54
+	private $tmp_sosa_table;
55
+
56
+	/**
57
+	 * Maximum number of generations to calculate
58
+	 * @var int $max_generations
59
+	 */
60
+	private $max_generations;
61
+
62
+	/**
63
+	 * Constructor for the Sosa Calculator
64
+	 *
65
+	 * @param SosaRecordsService $sosa_records_service
66
+	 * @param Tree $tree
67
+	 * @param UserInterface $user
68
+	 */
69
+	public function __construct(SosaRecordsService $sosa_records_service, Tree $tree, UserInterface $user)
70
+	{
71
+		$this->sosa_records_service = $sosa_records_service;
72
+		$this->tree = $tree;
73
+		$this->user = $user;
74
+		$this->tmp_sosa_table = array();
75
+		$max_gen_setting = $tree->getUserPreference($user, 'MAJ_SOSA_MAX_GEN');
76
+		$this->max_generations = is_numeric($max_gen_setting) ?
77
+			(int) $max_gen_setting :
78
+			$this->sosa_records_service->maxSystemGenerations();
79
+	}
80
+
81
+	/**
82
+	 * Compute all Sosa ancestors from the user's root individual.
83
+	 *
84
+	 * @return bool Result of the computation
85
+	 */
86
+	public function computeAll(): bool
87
+	{
88
+		$root_id = $this->tree->getUserPreference($this->user, 'MAJ_SOSA_ROOT_ID');
89
+		if (($indi = Registry::individualFactory()->make($root_id, $this->tree)) !== null) {
90
+			$this->sosa_records_service->deleteAll($this->tree, $this->user);
91
+			$this->addNode($indi, 1);
92
+			$this->flushTmpSosaTable(true);
93
+			return true;
94
+		}
95
+		return false;
96
+	}
97
+
98
+	/**
99
+	 * Compute all Sosa Ancestors from a specified Individual
100
+	 *
101
+	 * @param Individual $indi
102
+	 * @return bool
103
+	 */
104
+	public function computeFromIndividual(Individual $indi): bool
105
+	{
106
+		$current_sosas = $this->sosa_records_service->sosaNumbers($this->tree, $this->user, $indi);
107
+		foreach ($current_sosas->keys() as $sosa) {
108
+			$this->sosa_records_service->deleteAncestorsFrom($this->tree, $this->user, $sosa);
109
+			$this->addNode($indi, $sosa);
110
+		}
111
+		$this->flushTmpSosaTable(true);
112
+		return true;
113
+	}
114
+
115
+	/**
116
+	 * Recursive method to add individual to the Sosa table, and flush it regularly
117
+	 *
118
+	 * @param Individual $indi Individual to add
119
+	 * @param int $sosa Individual's sosa
120
+	 */
121
+	private function addNode(Individual $indi, int $sosa): void
122
+	{
123
+		$birth_year = $indi->getBirthDate()->gregorianYear();
124
+		$birth_year_est = $birth_year === 0 ? $indi->getEstimatedBirthDate()->gregorianYear() : $birth_year;
125
+
126
+		$death_year = $indi->getDeathDate()->gregorianYear();
127
+		$death_year_est = $death_year === 0 ? $indi->getEstimatedDeathDate()->gregorianYear() : $death_year;
128
+
129
+		$this->tmp_sosa_table[] = [
130
+			'indi' => $indi->xref(),
131
+			'sosa' => $sosa,
132
+			'birth_year' => $birth_year === 0 ? null : $birth_year,
133
+			'birth_year_est' => $birth_year_est === 0 ? null : $birth_year_est,
134
+			'death_year' => $death_year === 0 ? null : $death_year,
135
+			'death_year_est' => $death_year_est === 0 ? null : $death_year_est
136
+		];
137
+
138
+		$this->flushTmpSosaTable();
139
+
140
+		if (
141
+			($fam = $indi->childFamilies()->first()) !== null
142
+			&& $this->sosa_records_service->generation($sosa) < $this->max_generations
143
+		) {
144
+			/** @var \Fisharebest\Webtrees\Family $fam */
145
+			if (($husb = $fam->husband()) !== null) {
146
+				$this->addNode($husb, 2 * $sosa);
147
+			}
148
+			if (($wife = $fam->wife()) !== null) {
149
+				$this->addNode($wife, 2 * $sosa + 1);
150
+			}
151
+		}
152
+	}
153
+
154
+	/**
155
+	 * Write sosas in the table, if the number of items is superior to the limit, or if forced.
156
+	 *
157
+	 * @param bool $force Should the flush be forced
158
+	 */
159
+	private function flushTmpSosaTable($force = false): void
160
+	{
161
+		if ($force || count($this->tmp_sosa_table) >= self::TMP_SOSA_TABLE_LIMIT) {
162
+			$this->sosa_records_service->insertOrUpdate($this->tree, $this->user, $this->tmp_sosa_table);
163
+			$this->tmp_sosa_table = array();
164
+		}
165
+	}
166 166
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -74,8 +74,7 @@
 block discarded – undo
74 74
         $this->tmp_sosa_table = array();
75 75
         $max_gen_setting = $tree->getUserPreference($user, 'MAJ_SOSA_MAX_GEN');
76 76
         $this->max_generations = is_numeric($max_gen_setting) ?
77
-            (int) $max_gen_setting :
78
-            $this->sosa_records_service->maxSystemGenerations();
77
+            (int)$max_gen_setting : $this->sosa_records_service->maxSystemGenerations();
79 78
     }
80 79
 
81 80
     /**
Please login to merge, or discard this patch.
app/Module/GeoDispersion/GeoDispersionModule.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
     // How to update the database schema for this module
77 77
     private const SCHEMA_TARGET_VERSION   = 3;
78 78
     private const SCHEMA_SETTING_NAME     = 'MAJ_GEODISP_SCHEMA_VERSION';
79
-    private const SCHEMA_MIGRATION_PREFIX = __NAMESPACE__ . '\Schema';
79
+    private const SCHEMA_MIGRATION_PREFIX = __NAMESPACE__.'\Schema';
80 80
 
81 81
     /**
82 82
      * {@inheritDoc}
@@ -126,13 +126,13 @@  discard block
 block discarded – undo
126 126
      */
127 127
     public function loadRoutes(Map $router): void
128 128
     {
129
-        $router->attach('', '', static function (Map $router): void {
129
+        $router->attach('', '', static function(Map $router): void {
130 130
 
131
-            $router->attach('', '/module-maj/geodispersion', static function (Map $router): void {
132
-                $router->attach('', '/admin', static function (Map $router): void {
131
+            $router->attach('', '/module-maj/geodispersion', static function(Map $router): void {
132
+                $router->attach('', '/admin', static function(Map $router): void {
133 133
                     $router->get(AdminConfigPage::class, '/config{/tree}', AdminConfigPage::class);
134 134
 
135
-                    $router->attach('', '/analysis-views/{tree}', static function (Map $router): void {
135
+                    $router->attach('', '/analysis-views/{tree}', static function(Map $router): void {
136 136
                         $router->tokens(['view_id' => '\d+', 'enable' => '[01]']);
137 137
                         $router->extras([
138 138
                             'middleware' => [
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
                         //phpcs:enable
152 152
                     });
153 153
 
154
-                    $router->attach('', '/map-adapters/{tree}', static function (Map $router): void {
154
+                    $router->attach('', '/map-adapters/{tree}', static function(Map $router): void {
155 155
                         $router->tokens(['adapter_id' => '\d+', 'view_id' => '\d+']);
156 156
                         $router->extras([
157 157
                             'middleware' => [
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
 
177 177
                 $router->get(GeoAnalysisViewsList::class, '/list/{tree}', GeoAnalysisViewsList::class);
178 178
 
179
-                $router->attach('', '/analysisview/{tree}/{view_id}', static function (Map $router): void {
179
+                $router->attach('', '/analysisview/{tree}/{view_id}', static function(Map $router): void {
180 180
                     $router->tokens(['view_id' => '\d+']);
181 181
                     $router->get(GeoAnalysisViewPage::class, '', GeoAnalysisViewPage::class);
182 182
                     $router->get(GeoAnalysisViewTabs::class, '/tabs', GeoAnalysisViewTabs::class);
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
      */
215 215
     public function headContent(): string
216 216
     {
217
-        return '<link rel="stylesheet" href="' . e($this->moduleCssUrl()) . '">';
217
+        return '<link rel="stylesheet" href="'.e($this->moduleCssUrl()).'">';
218 218
     }
219 219
 
220 220
     /**
Please login to merge, or discard this patch.
Indentation   +183 added lines, -183 removed lines patch added patch discarded remove patch
@@ -59,188 +59,188 @@
 block discarded – undo
59 59
  * Geographical Dispersion Module.
60 60
  */
61 61
 class GeoDispersionModule extends AbstractModule implements
62
-    ModuleMyArtJaubInterface,
63
-    ModuleChartInterface,
64
-    ModuleConfigInterface,
65
-    ModuleGlobalInterface,
66
-    ModuleGeoAnalysisProviderInterface,
67
-    ModulePlaceMapperProviderInterface
62
+	ModuleMyArtJaubInterface,
63
+	ModuleChartInterface,
64
+	ModuleConfigInterface,
65
+	ModuleGlobalInterface,
66
+	ModuleGeoAnalysisProviderInterface,
67
+	ModulePlaceMapperProviderInterface
68 68
 {
69
-    use ModuleMyArtJaubTrait {
70
-        boot as traitBoot;
71
-    }
72
-    use ModuleChartTrait;
73
-    use ModuleConfigTrait;
74
-    use ModuleGlobalTrait;
75
-
76
-    // How to update the database schema for this module
77
-    private const SCHEMA_TARGET_VERSION   = 3;
78
-    private const SCHEMA_SETTING_NAME     = 'MAJ_GEODISP_SCHEMA_VERSION';
79
-    private const SCHEMA_MIGRATION_PREFIX = __NAMESPACE__ . '\Schema';
80
-
81
-    /**
82
-     * {@inheritDoc}
83
-     * @see \Fisharebest\Webtrees\Module\AbstractModule::title()
84
-     */
85
-    public function title(): string
86
-    {
87
-        return /* I18N: Name of the “GeoDispersion” module */ I18N::translate('Geographical dispersion');
88
-    }
89
-
90
-    /**
91
-     * {@inheritDoc}
92
-     * @see \Fisharebest\Webtrees\Module\AbstractModule::description()
93
-     */
94
-    public function description(): string
95
-    {
96
-        //phpcs:ignore Generic.Files.LineLength.TooLong
97
-        return /* I18N: Description of the “GeoDispersion” module */ I18N::translate('Perform and display geographical dispersion analyses.');
98
-    }
99
-
100
-    /**
101
-     * {@inheritDoc}
102
-     * @see \Fisharebest\Webtrees\Module\AbstractModule::boot()
103
-     */
104
-    public function boot(): void
105
-    {
106
-        $this->traitBoot();
107
-        app(MigrationService::class)->updateSchema(
108
-            self::SCHEMA_MIGRATION_PREFIX,
109
-            self::SCHEMA_SETTING_NAME,
110
-            self::SCHEMA_TARGET_VERSION
111
-        );
112
-    }
113
-
114
-    /**
115
-     * {@inheritDoc}
116
-     * @see \Fisharebest\Webtrees\Module\ModuleCustomInterface::customModuleVersion()
117
-     */
118
-    public function customModuleVersion(): string
119
-    {
120
-        return '2.1.18-v.2';
121
-    }
122
-
123
-    /**
124
-     * {@inheritDoc}
125
-     * @see \MyArtJaub\Webtrees\Module\ModuleMyArtJaubInterface::loadRoutes()
126
-     */
127
-    public function loadRoutes(Map $router): void
128
-    {
129
-        $router->attach('', '', static function (Map $router): void {
130
-
131
-            $router->attach('', '/module-maj/geodispersion', static function (Map $router): void {
132
-                $router->attach('', '/admin', static function (Map $router): void {
133
-                    $router->get(AdminConfigPage::class, '/config{/tree}', AdminConfigPage::class);
134
-
135
-                    $router->attach('', '/analysis-views/{tree}', static function (Map $router): void {
136
-                        $router->tokens(['view_id' => '\d+', 'enable' => '[01]']);
137
-                        $router->extras([
138
-                            'middleware' => [
139
-                                AuthManager::class,
140
-                            ],
141
-                        ]);
142
-                        $router->get(GeoAnalysisViewListData::class, '', GeoAnalysisViewListData::class);
143
-
144
-                        $router->get(GeoAnalysisViewAddPage::class, '/add', GeoAnalysisViewAddPage::class);
145
-                        $router->post(GeoAnalysisViewAddAction::class, '/add', GeoAnalysisViewAddAction::class);
146
-                        $router->get(GeoAnalysisViewEditPage::class, '/{view_id}', GeoAnalysisViewEditPage::class);
147
-                        $router->post(GeoAnalysisViewEditAction::class, '/{view_id}', GeoAnalysisViewEditAction::class);
148
-                        //phpcs:disable Generic.Files.LineLength.TooLong
149
-                        $router->get(GeoAnalysisViewStatusAction::class, '/{view_id}/status/{enable}', GeoAnalysisViewStatusAction::class);
150
-                        $router->get(GeoAnalysisViewDeleteAction::class, '/{view_id}/delete', GeoAnalysisViewDeleteAction::class);
151
-                        //phpcs:enable
152
-                    });
153
-
154
-                    $router->attach('', '/map-adapters/{tree}', static function (Map $router): void {
155
-                        $router->tokens(['adapter_id' => '\d+', 'view_id' => '\d+']);
156
-                        $router->extras([
157
-                            'middleware' => [
158
-                                AuthManager::class,
159
-                            ],
160
-                        ]);
161
-
162
-                        $router->get(MapAdapterAddPage::class, '/add/{view_id}', MapAdapterAddPage::class);
163
-                        $router->post(MapAdapterAddAction::class, '/add/{view_id}', MapAdapterAddAction::class);
164
-                        $router->get(MapAdapterEditPage::class, '/{adapter_id}', MapAdapterEditPage::class);
165
-                        $router->post(MapAdapterEditAction::class, '/{adapter_id}', MapAdapterEditAction::class);
166
-                        //phpcs:disable Generic.Files.LineLength.TooLong
167
-                        $router->get(MapAdapterDeleteAction::class, '/{adapter_id}/delete', MapAdapterDeleteAction::class);
168
-                        $router->get(MapAdapterDeleteInvalidAction::class, '/delete-invalid/{view_id}', MapAdapterDeleteInvalidAction::class);
169
-                        $router->get(MapAdapterMapperConfig::class, '/mapper/config{/adapter_id}', MapAdapterMapperConfig::class);
170
-                        //phpcs:enable
171
-                    });
172
-
173
-                    //phpcs:ignore Generic.Files.LineLength.TooLong
174
-                    $router->get(MapFeaturePropertyData::class, '/map/feature-properties{/map_id}', MapFeaturePropertyData::class);
175
-                });
176
-
177
-                $router->get(GeoAnalysisViewsList::class, '/list/{tree}', GeoAnalysisViewsList::class);
178
-
179
-                $router->attach('', '/analysisview/{tree}/{view_id}', static function (Map $router): void {
180
-                    $router->tokens(['view_id' => '\d+']);
181
-                    $router->get(GeoAnalysisViewPage::class, '', GeoAnalysisViewPage::class);
182
-                    $router->get(GeoAnalysisViewTabs::class, '/tabs', GeoAnalysisViewTabs::class);
183
-                });
184
-            });
185
-        });
186
-    }
187
-
188
-    public function getConfigLink(): string
189
-    {
190
-        return route(AdminConfigPage::class);
191
-    }
192
-
193
-    /**
194
-     * {@inheritDoc}
195
-     * @see \Fisharebest\Webtrees\Module\ModuleChartInterface::chartUrl()
196
-     *
197
-     * @param array<bool|int|string|array<mixed>|null> $parameters
198
-     */
199
-    public function chartUrl(Individual $individual, array $parameters = []): string
200
-    {
201
-        return route(GeoAnalysisViewsList::class, ['tree' => $individual->tree()->name()] + $parameters);
202
-    }
203
-
204
-    /**
205
-     * {@inheritDoc}
206
-     * @see \Fisharebest\Webtrees\Module\ModuleChartInterface::chartMenuClass()
207
-     */
208
-    public function chartMenuClass(): string
209
-    {
210
-        return 'menu-maj-geodispersion';
211
-    }
212
-
213
-    /**
214
-     * {@inheritDoc}
215
-     * @see \Fisharebest\Webtrees\Module\ModuleGlobalInterface::headContent()
216
-     */
217
-    public function headContent(): string
218
-    {
219
-        return '<link rel="stylesheet" href="' . e($this->moduleCssUrl()) . '">';
220
-    }
221
-
222
-    /**
223
-     * {@inheritDoc}
224
-     * @see \MyArtJaub\Webtrees\Contracts\GeoDispersion\ModulePlaceMapperProviderInterface::listPlaceMappers()
225
-     */
226
-    public function listPlaceMappers(): array
227
-    {
228
-        return [
229
-            CoordinatesPlaceMapper::class,
230
-            SimplePlaceMapper::class,
231
-            SimpleTopFilteredPlaceMapper::class
232
-        ];
233
-    }
234
-
235
-    /**
236
-     * {@inheritDoc}
237
-     * @see \MyArtJaub\Webtrees\Contracts\GeoDispersion\ModuleGeoAnalysisProviderInterface::listGeoAnalyses()
238
-     */
239
-    public function listGeoAnalyses(): array
240
-    {
241
-        return [
242
-            AllEventsByCenturyGeoAnalysis::class,
243
-            AllEventsByTypeGeoAnalysis::class
244
-        ];
245
-    }
69
+	use ModuleMyArtJaubTrait {
70
+		boot as traitBoot;
71
+	}
72
+	use ModuleChartTrait;
73
+	use ModuleConfigTrait;
74
+	use ModuleGlobalTrait;
75
+
76
+	// How to update the database schema for this module
77
+	private const SCHEMA_TARGET_VERSION   = 3;
78
+	private const SCHEMA_SETTING_NAME     = 'MAJ_GEODISP_SCHEMA_VERSION';
79
+	private const SCHEMA_MIGRATION_PREFIX = __NAMESPACE__ . '\Schema';
80
+
81
+	/**
82
+	 * {@inheritDoc}
83
+	 * @see \Fisharebest\Webtrees\Module\AbstractModule::title()
84
+	 */
85
+	public function title(): string
86
+	{
87
+		return /* I18N: Name of the “GeoDispersion” module */ I18N::translate('Geographical dispersion');
88
+	}
89
+
90
+	/**
91
+	 * {@inheritDoc}
92
+	 * @see \Fisharebest\Webtrees\Module\AbstractModule::description()
93
+	 */
94
+	public function description(): string
95
+	{
96
+		//phpcs:ignore Generic.Files.LineLength.TooLong
97
+		return /* I18N: Description of the “GeoDispersion” module */ I18N::translate('Perform and display geographical dispersion analyses.');
98
+	}
99
+
100
+	/**
101
+	 * {@inheritDoc}
102
+	 * @see \Fisharebest\Webtrees\Module\AbstractModule::boot()
103
+	 */
104
+	public function boot(): void
105
+	{
106
+		$this->traitBoot();
107
+		app(MigrationService::class)->updateSchema(
108
+			self::SCHEMA_MIGRATION_PREFIX,
109
+			self::SCHEMA_SETTING_NAME,
110
+			self::SCHEMA_TARGET_VERSION
111
+		);
112
+	}
113
+
114
+	/**
115
+	 * {@inheritDoc}
116
+	 * @see \Fisharebest\Webtrees\Module\ModuleCustomInterface::customModuleVersion()
117
+	 */
118
+	public function customModuleVersion(): string
119
+	{
120
+		return '2.1.18-v.2';
121
+	}
122
+
123
+	/**
124
+	 * {@inheritDoc}
125
+	 * @see \MyArtJaub\Webtrees\Module\ModuleMyArtJaubInterface::loadRoutes()
126
+	 */
127
+	public function loadRoutes(Map $router): void
128
+	{
129
+		$router->attach('', '', static function (Map $router): void {
130
+
131
+			$router->attach('', '/module-maj/geodispersion', static function (Map $router): void {
132
+				$router->attach('', '/admin', static function (Map $router): void {
133
+					$router->get(AdminConfigPage::class, '/config{/tree}', AdminConfigPage::class);
134
+
135
+					$router->attach('', '/analysis-views/{tree}', static function (Map $router): void {
136
+						$router->tokens(['view_id' => '\d+', 'enable' => '[01]']);
137
+						$router->extras([
138
+							'middleware' => [
139
+								AuthManager::class,
140
+							],
141
+						]);
142
+						$router->get(GeoAnalysisViewListData::class, '', GeoAnalysisViewListData::class);
143
+
144
+						$router->get(GeoAnalysisViewAddPage::class, '/add', GeoAnalysisViewAddPage::class);
145
+						$router->post(GeoAnalysisViewAddAction::class, '/add', GeoAnalysisViewAddAction::class);
146
+						$router->get(GeoAnalysisViewEditPage::class, '/{view_id}', GeoAnalysisViewEditPage::class);
147
+						$router->post(GeoAnalysisViewEditAction::class, '/{view_id}', GeoAnalysisViewEditAction::class);
148
+						//phpcs:disable Generic.Files.LineLength.TooLong
149
+						$router->get(GeoAnalysisViewStatusAction::class, '/{view_id}/status/{enable}', GeoAnalysisViewStatusAction::class);
150
+						$router->get(GeoAnalysisViewDeleteAction::class, '/{view_id}/delete', GeoAnalysisViewDeleteAction::class);
151
+						//phpcs:enable
152
+					});
153
+
154
+					$router->attach('', '/map-adapters/{tree}', static function (Map $router): void {
155
+						$router->tokens(['adapter_id' => '\d+', 'view_id' => '\d+']);
156
+						$router->extras([
157
+							'middleware' => [
158
+								AuthManager::class,
159
+							],
160
+						]);
161
+
162
+						$router->get(MapAdapterAddPage::class, '/add/{view_id}', MapAdapterAddPage::class);
163
+						$router->post(MapAdapterAddAction::class, '/add/{view_id}', MapAdapterAddAction::class);
164
+						$router->get(MapAdapterEditPage::class, '/{adapter_id}', MapAdapterEditPage::class);
165
+						$router->post(MapAdapterEditAction::class, '/{adapter_id}', MapAdapterEditAction::class);
166
+						//phpcs:disable Generic.Files.LineLength.TooLong
167
+						$router->get(MapAdapterDeleteAction::class, '/{adapter_id}/delete', MapAdapterDeleteAction::class);
168
+						$router->get(MapAdapterDeleteInvalidAction::class, '/delete-invalid/{view_id}', MapAdapterDeleteInvalidAction::class);
169
+						$router->get(MapAdapterMapperConfig::class, '/mapper/config{/adapter_id}', MapAdapterMapperConfig::class);
170
+						//phpcs:enable
171
+					});
172
+
173
+					//phpcs:ignore Generic.Files.LineLength.TooLong
174
+					$router->get(MapFeaturePropertyData::class, '/map/feature-properties{/map_id}', MapFeaturePropertyData::class);
175
+				});
176
+
177
+				$router->get(GeoAnalysisViewsList::class, '/list/{tree}', GeoAnalysisViewsList::class);
178
+
179
+				$router->attach('', '/analysisview/{tree}/{view_id}', static function (Map $router): void {
180
+					$router->tokens(['view_id' => '\d+']);
181
+					$router->get(GeoAnalysisViewPage::class, '', GeoAnalysisViewPage::class);
182
+					$router->get(GeoAnalysisViewTabs::class, '/tabs', GeoAnalysisViewTabs::class);
183
+				});
184
+			});
185
+		});
186
+	}
187
+
188
+	public function getConfigLink(): string
189
+	{
190
+		return route(AdminConfigPage::class);
191
+	}
192
+
193
+	/**
194
+	 * {@inheritDoc}
195
+	 * @see \Fisharebest\Webtrees\Module\ModuleChartInterface::chartUrl()
196
+	 *
197
+	 * @param array<bool|int|string|array<mixed>|null> $parameters
198
+	 */
199
+	public function chartUrl(Individual $individual, array $parameters = []): string
200
+	{
201
+		return route(GeoAnalysisViewsList::class, ['tree' => $individual->tree()->name()] + $parameters);
202
+	}
203
+
204
+	/**
205
+	 * {@inheritDoc}
206
+	 * @see \Fisharebest\Webtrees\Module\ModuleChartInterface::chartMenuClass()
207
+	 */
208
+	public function chartMenuClass(): string
209
+	{
210
+		return 'menu-maj-geodispersion';
211
+	}
212
+
213
+	/**
214
+	 * {@inheritDoc}
215
+	 * @see \Fisharebest\Webtrees\Module\ModuleGlobalInterface::headContent()
216
+	 */
217
+	public function headContent(): string
218
+	{
219
+		return '<link rel="stylesheet" href="' . e($this->moduleCssUrl()) . '">';
220
+	}
221
+
222
+	/**
223
+	 * {@inheritDoc}
224
+	 * @see \MyArtJaub\Webtrees\Contracts\GeoDispersion\ModulePlaceMapperProviderInterface::listPlaceMappers()
225
+	 */
226
+	public function listPlaceMappers(): array
227
+	{
228
+		return [
229
+			CoordinatesPlaceMapper::class,
230
+			SimplePlaceMapper::class,
231
+			SimpleTopFilteredPlaceMapper::class
232
+		];
233
+	}
234
+
235
+	/**
236
+	 * {@inheritDoc}
237
+	 * @see \MyArtJaub\Webtrees\Contracts\GeoDispersion\ModuleGeoAnalysisProviderInterface::listGeoAnalyses()
238
+	 */
239
+	public function listGeoAnalyses(): array
240
+	{
241
+		return [
242
+			AllEventsByCenturyGeoAnalysis::class,
243
+			AllEventsByTypeGeoAnalysis::class
244
+		];
245
+	}
246 246
 }
Please login to merge, or discard this patch.
app/Module/GeoDispersion/Http/RequestHandlers/GeoAnalysisViewsList.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -67,7 +67,7 @@
 block discarded – undo
67 67
             ->all($tree)
68 68
             ->sortBy(fn(AbstractGeoAnalysisView $view) => $view->description());
69 69
 
70
-        return $this->viewResponse($this->module->name() . '::geoanalysisviews-list', [
70
+        return $this->viewResponse($this->module->name().'::geoanalysisviews-list', [
71 71
             'module'        =>  $this->module,
72 72
             'title'         =>  I18N::translate('Geographical dispersion'),
73 73
             'tree'          =>  $tree,
Please login to merge, or discard this patch.
Indentation   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -33,46 +33,46 @@
 block discarded – undo
33 33
  */
34 34
 class GeoAnalysisViewsList implements RequestHandlerInterface
35 35
 {
36
-    use ViewResponseTrait;
36
+	use ViewResponseTrait;
37 37
 
38
-    private ?GeoDispersionModule $module;
39
-    private GeoAnalysisViewDataService $geoviewdata_service;
38
+	private ?GeoDispersionModule $module;
39
+	private GeoAnalysisViewDataService $geoviewdata_service;
40 40
 
41
-    /**
42
-     * Constructor for GeoAnalysisViewsList Request Handler
43
-     *
44
-     * @param ModuleService $module_service
45
-     */
46
-    public function __construct(
47
-        ModuleService $module_service,
48
-        GeoAnalysisViewDataService $geoviewdata_service
49
-    ) {
50
-        $this->module = $module_service->findByInterface(GeoDispersionModule::class)->first();
51
-        $this->geoviewdata_service = $geoviewdata_service;
52
-    }
41
+	/**
42
+	 * Constructor for GeoAnalysisViewsList Request Handler
43
+	 *
44
+	 * @param ModuleService $module_service
45
+	 */
46
+	public function __construct(
47
+		ModuleService $module_service,
48
+		GeoAnalysisViewDataService $geoviewdata_service
49
+	) {
50
+		$this->module = $module_service->findByInterface(GeoDispersionModule::class)->first();
51
+		$this->geoviewdata_service = $geoviewdata_service;
52
+	}
53 53
 
54
-    /**
55
-     * {@inheritDoc}
56
-     * @see \Psr\Http\Server\RequestHandlerInterface::handle()
57
-     */
58
-    public function handle(ServerRequestInterface $request): ResponseInterface
59
-    {
60
-        if ($this->module === null) {
61
-            throw new HttpNotFoundException(I18N::translate('The attached module could not be found.'));
62
-        }
54
+	/**
55
+	 * {@inheritDoc}
56
+	 * @see \Psr\Http\Server\RequestHandlerInterface::handle()
57
+	 */
58
+	public function handle(ServerRequestInterface $request): ResponseInterface
59
+	{
60
+		if ($this->module === null) {
61
+			throw new HttpNotFoundException(I18N::translate('The attached module could not be found.'));
62
+		}
63 63
 
64
-        $tree = Validator::attributes($request)->tree();
64
+		$tree = Validator::attributes($request)->tree();
65 65
 
66
-        $views_list = $this->geoviewdata_service
67
-            ->all($tree)
68
-            ->sortBy(fn(AbstractGeoAnalysisView $view) => $view->description());
66
+		$views_list = $this->geoviewdata_service
67
+			->all($tree)
68
+			->sortBy(fn(AbstractGeoAnalysisView $view) => $view->description());
69 69
 
70
-        return $this->viewResponse($this->module->name() . '::geoanalysisviews-list', [
71
-            'module'        =>  $this->module,
72
-            'title'         =>  I18N::translate('Geographical dispersion'),
73
-            'tree'          =>  $tree,
74
-            'views_list'    =>  $views_list,
75
-            'js_script_url' =>  $this->module->assetUrl('js/geodispersion.min.js')
76
-        ]);
77
-    }
70
+		return $this->viewResponse($this->module->name() . '::geoanalysisviews-list', [
71
+			'module'        =>  $this->module,
72
+			'title'         =>  I18N::translate('Geographical dispersion'),
73
+			'tree'          =>  $tree,
74
+			'views_list'    =>  $views_list,
75
+			'js_script_url' =>  $this->module->assetUrl('js/geodispersion.min.js')
76
+		]);
77
+	}
78 78
 }
Please login to merge, or discard this patch.
app/Module/GeoDispersion/Http/RequestHandlers/AdminConfigPage.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -87,7 +87,7 @@
 block discarded – undo
87 87
             throw new HttpAccessDeniedException();
88 88
         }
89 89
 
90
-        return $this->viewResponse($this->module->name() . '::admin/config', [
90
+        return $this->viewResponse($this->module->name().'::admin/config', [
91 91
             'module_name'       =>  $this->module->name(),
92 92
             'title'             =>  $this->module->title(),
93 93
             'tree'              =>  $tree,
Please login to merge, or discard this patch.
Indentation   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -35,64 +35,64 @@
 block discarded – undo
35 35
  */
36 36
 class AdminConfigPage implements RequestHandlerInterface
37 37
 {
38
-    use ViewResponseTrait;
39
-
40
-    private ?GeoDispersionModule $module;
41
-
42
-    private TreeService $tree_service;
43
-
44
-    private GeoAnalysisDataService $geoanalysis_data_service;
45
-
46
-    /**
47
-     * Constructor for the AdminConfigPage Request Handler
48
-     *
49
-     * @param ModuleService $module_service
50
-     * @param TreeService $tree_service
51
-     * @param GeoAnalysisDataService $geoanalysis_data_service
52
-     */
53
-    public function __construct(
54
-        ModuleService $module_service,
55
-        TreeService $tree_service,
56
-        GeoAnalysisDataService $geoanalysis_data_service
57
-    ) {
58
-        $this->module = $module_service->findByInterface(GeoDispersionModule::class)->first();
59
-        $this->tree_service = $tree_service;
60
-        $this->geoanalysis_data_service = $geoanalysis_data_service;
61
-    }
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';
70
-
71
-        if ($this->module === null) {
72
-            throw new HttpNotFoundException(I18N::translate('The attached module could not be found.'));
73
-        }
74
-
75
-        $user = Validator::attributes($request)->user();
76
-
77
-        $all_trees = $this->tree_service->all()->filter(fn(Tree $tree) => Auth::isManager($tree, $user));
78
-        if ($all_trees->count() === 0) {
79
-            throw new HttpAccessDeniedException();
80
-        }
81
-
82
-        $tree = Validator::attributes($request)->treeOptional() ?? $all_trees->first();
83
-
84
-        $same_tree = fn(Tree $tree_collection): bool => $tree->id() === $tree_collection->id();
85
-        if (!$all_trees->contains($same_tree)) {
86
-            throw new HttpAccessDeniedException();
87
-        }
88
-
89
-        return $this->viewResponse($this->module->name() . '::admin/config', [
90
-            'module_name'       =>  $this->module->name(),
91
-            'title'             =>  $this->module->title(),
92
-            'tree'              =>  $tree,
93
-            'other_trees'       =>  $all_trees->reject($same_tree),
94
-            'place_example'     =>  $this->geoanalysis_data_service->placeHierarchyExample($tree),
95
-            'js_script_url'     =>  $this->module->assetUrl('js/geodispersion.min.js')
96
-        ]);
97
-    }
38
+	use ViewResponseTrait;
39
+
40
+	private ?GeoDispersionModule $module;
41
+
42
+	private TreeService $tree_service;
43
+
44
+	private GeoAnalysisDataService $geoanalysis_data_service;
45
+
46
+	/**
47
+	 * Constructor for the AdminConfigPage Request Handler
48
+	 *
49
+	 * @param ModuleService $module_service
50
+	 * @param TreeService $tree_service
51
+	 * @param GeoAnalysisDataService $geoanalysis_data_service
52
+	 */
53
+	public function __construct(
54
+		ModuleService $module_service,
55
+		TreeService $tree_service,
56
+		GeoAnalysisDataService $geoanalysis_data_service
57
+	) {
58
+		$this->module = $module_service->findByInterface(GeoDispersionModule::class)->first();
59
+		$this->tree_service = $tree_service;
60
+		$this->geoanalysis_data_service = $geoanalysis_data_service;
61
+	}
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';
70
+
71
+		if ($this->module === null) {
72
+			throw new HttpNotFoundException(I18N::translate('The attached module could not be found.'));
73
+		}
74
+
75
+		$user = Validator::attributes($request)->user();
76
+
77
+		$all_trees = $this->tree_service->all()->filter(fn(Tree $tree) => Auth::isManager($tree, $user));
78
+		if ($all_trees->count() === 0) {
79
+			throw new HttpAccessDeniedException();
80
+		}
81
+
82
+		$tree = Validator::attributes($request)->treeOptional() ?? $all_trees->first();
83
+
84
+		$same_tree = fn(Tree $tree_collection): bool => $tree->id() === $tree_collection->id();
85
+		if (!$all_trees->contains($same_tree)) {
86
+			throw new HttpAccessDeniedException();
87
+		}
88
+
89
+		return $this->viewResponse($this->module->name() . '::admin/config', [
90
+			'module_name'       =>  $this->module->name(),
91
+			'title'             =>  $this->module->title(),
92
+			'tree'              =>  $tree,
93
+			'other_trees'       =>  $all_trees->reject($same_tree),
94
+			'place_example'     =>  $this->geoanalysis_data_service->placeHierarchyExample($tree),
95
+			'js_script_url'     =>  $this->module->assetUrl('js/geodispersion.min.js')
96
+		]);
97
+	}
98 98
 }
Please login to merge, or discard this patch.