Passed
Branch main (f9aaf7)
by Jonathan
14:43
created
app/Contracts/GeoDispersion/PlaceMapperConfigInterface.php 1 patch
Indentation   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -24,45 +24,45 @@
 block discarded – undo
24 24
  */
25 25
 interface PlaceMapperConfigInterface extends JsonSerializable
26 26
 {
27
-    /**
28
-     * Deserialise the mapper configuration from a string or an array
29
-     *
30
-     * @param mixed $config
31
-     * @return $this
32
-     */
33
-    public function jsonDeserialize($config): self;
27
+	/**
28
+	 * Deserialise the mapper configuration from a string or an array
29
+	 *
30
+	 * @param mixed $config
31
+	 * @return $this
32
+	 */
33
+	public function jsonDeserialize($config): self;
34 34
 
35
-    /**
36
-     * Check if the configuration contains a specific key
37
-     *
38
-     * @param string $key
39
-     * @return bool
40
-     */
41
-    public function has(string $key): bool;
35
+	/**
36
+	 * Check if the configuration contains a specific key
37
+	 *
38
+	 * @param string $key
39
+	 * @return bool
40
+	 */
41
+	public function has(string $key): bool;
42 42
 
43
-    /**
44
-     * Return the configuration associated with a key, or a default value if none found.
45
-     *
46
-     * @param string $key
47
-     * @param mixed|null $default
48
-     * @return mixed|null
49
-     */
50
-    public function get(string $key, $default = null);
43
+	/**
44
+	 * Return the configuration associated with a key, or a default value if none found.
45
+	 *
46
+	 * @param string $key
47
+	 * @param mixed|null $default
48
+	 * @return mixed|null
49
+	 */
50
+	public function get(string $key, $default = null);
51 51
 
52
-    /**
53
-     * Return the content of the mapper configuration section of the config page
54
-     *
55
-     * @param ModuleInterface $module
56
-     * @param Tree $tree
57
-     * @return string
58
-     */
59
-    public function configContent(ModuleInterface $module, Tree $tree): string;
52
+	/**
53
+	 * Return the content of the mapper configuration section of the config page
54
+	 *
55
+	 * @param ModuleInterface $module
56
+	 * @param Tree $tree
57
+	 * @return string
58
+	 */
59
+	public function configContent(ModuleInterface $module, Tree $tree): string;
60 60
 
61
-    /**
62
-     * Return a PlaceMapperConfigInterface object updated according to its mapper configuration rules
63
-     *
64
-     * @param ServerRequestInterface $request
65
-     * @return static
66
-     */
67
-    public function withConfigUpdate(ServerRequestInterface $request): self;
61
+	/**
62
+	 * Return a PlaceMapperConfigInterface object updated according to its mapper configuration rules
63
+	 *
64
+	 * @param ServerRequestInterface $request
65
+	 * @return static
66
+	 */
67
+	public function withConfigUpdate(ServerRequestInterface $request): self;
68 68
 }
Please login to merge, or discard this patch.
app/Contracts/Tasks/TaskInterface.php 1 patch
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -19,25 +19,25 @@
 block discarded – undo
19 19
  */
20 20
 interface TaskInterface
21 21
 {
22
-    /**
23
-     * Display name of the task
24
-     *
25
-     * @return string
26
-     */
27
-    public function name(): string;
22
+	/**
23
+	 * Display name of the task
24
+	 *
25
+	 * @return string
26
+	 */
27
+	public function name(): string;
28 28
     
29
-    /**
30
-     * Return the default frequency for the execution of the task, in minutes.
31
-     *
32
-     * @return int Frequency for the execution of the task
33
-     */
34
-    public function defaultFrequency(): int;
29
+	/**
30
+	 * Return the default frequency for the execution of the task, in minutes.
31
+	 *
32
+	 * @return int Frequency for the execution of the task
33
+	 */
34
+	public function defaultFrequency(): int;
35 35
     
36
-    /**
37
-     * Run the task's actions, and return whether the execution has been successful.
38
-     *
39
-     * @param TaskSchedule $task_schedule
40
-     * @return bool Has the execution been a success
41
-     */
42
-    public function run(TaskSchedule $task_schedule): bool;
36
+	/**
37
+	 * Run the task's actions, and return whether the execution has been successful.
38
+	 *
39
+	 * @param TaskSchedule $task_schedule
40
+	 * @return bool Has the execution been a success
41
+	 */
42
+	public function run(TaskSchedule $task_schedule): bool;
43 43
 }
Please login to merge, or discard this patch.
app/Contracts/Tasks/ConfigurableTaskInterface.php 1 patch
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -22,20 +22,20 @@
 block discarded – undo
22 22
 interface ConfigurableTaskInterface
23 23
 {
24 24
     
25
-    /**
26
-     * Returns the HTML code to display the specific task configuration.
27
-     *
28
-     * @param ServerRequestInterface $request
29
-     * @return string HTML code
30
-     */
31
-    public function configView(ServerRequestInterface $request): string;
25
+	/**
26
+	 * Returns the HTML code to display the specific task configuration.
27
+	 *
28
+	 * @param ServerRequestInterface $request
29
+	 * @return string HTML code
30
+	 */
31
+	public function configView(ServerRequestInterface $request): string;
32 32
  
33
-    /**
34
-     * Update the specific configuration of the task.
35
-     *
36
-     * @param ServerRequestInterface $request
37
-     * @param TaskSchedule $task_schedule
38
-     * @return bool Result of the update
39
-     */
40
-    public function updateConfig(ServerRequestInterface $request, TaskSchedule $task_schedule): bool;
33
+	/**
34
+	 * Update the specific configuration of the task.
35
+	 *
36
+	 * @param ServerRequestInterface $request
37
+	 * @param TaskSchedule $task_schedule
38
+	 * @return bool Result of the update
39
+	 */
40
+	public function updateConfig(ServerRequestInterface $request, TaskSchedule $task_schedule): bool;
41 41
 }
Please login to merge, or discard this patch.
app/Contracts/Tasks/ModuleTasksProviderInterface.php 1 patch
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -20,11 +20,11 @@
 block discarded – undo
20 20
 interface ModuleTasksProviderInterface
21 21
 {
22 22
     
23
-    /**
24
-     * List tasks provided by the module as an associative array.
25
-     * They keys are used as task IDs for storage and reference.
26
-     *
27
-     * @return array<string, string> List of tasks
28
-     */
29
-    public function listTasks(): array;
23
+	/**
24
+	 * List tasks provided by the module as an associative array.
25
+	 * They keys are used as task IDs for storage and reference.
26
+	 *
27
+	 * @return array<string, string> List of tasks
28
+	 */
29
+	public function listTasks(): array;
30 30
 }
Please login to merge, or discard this patch.
app/Module/PatronymicLineage/PatronymicLineageModule.php 2 patches
Indentation   +95 added lines, -95 removed lines patch added patch discarded remove patch
@@ -34,100 +34,100 @@
 block discarded – undo
34 34
  * Display lineages of people with the same surname.
35 35
  */
36 36
 class PatronymicLineageModule extends IndividualListModule implements
37
-    ModuleMyArtJaubInterface,
38
-    ModuleListInterface,
39
-    ModuleGlobalInterface
37
+	ModuleMyArtJaubInterface,
38
+	ModuleListInterface,
39
+	ModuleGlobalInterface
40 40
 {
41
-    use ModuleMyArtJaubTrait;
42
-    use ModuleListTrait;
43
-    use ModuleGlobalTrait;
44
-
45
-     /**
46
-     * {@inheritDoc}
47
-     * @see \Fisharebest\Webtrees\Module\AbstractModule::title()
48
-     */
49
-    public function title(): string
50
-    {
51
-        return /* I18N: Name of the “Patronymic lineage” module */ I18N::translate('Patronymic Lineages');
52
-    }
53
-
54
-    /**
55
-     * {@inheritDoc}
56
-     * @see \Fisharebest\Webtrees\Module\AbstractModule::description()
57
-     */
58
-    public function description(): string
59
-    {
60
-        //phpcs:ignore Generic.Files.LineLength.TooLong
61
-        return /* I18N: Description of the “Patronymic lineage” module */ I18N::translate('Display lineages of people holding the same surname.');
62
-    }
63
-
64
-    /**
65
-     * {@inheritDoc}
66
-     * @see \MyArtJaub\Webtrees\Module\ModuleMyArtJaubInterface::loadRoutes()
67
-     */
68
-    public function loadRoutes(Map $router): void
69
-    {
70
-        $router->attach('', '', static function (Map $router): void {
71
-
72
-            $router->attach('', '/module-maj/lineages', static function (Map $router): void {
73
-
74
-                $router->attach('', '/Page', static function (Map $router): void {
75
-
76
-                    $router->get(SurnamesList::class, '/{tree}/list{/alpha}', SurnamesList::class);
77
-                    $router->get(LineagesPage::class, '/{tree}/lineage/{surname}', LineagesPage::class);
78
-                });
79
-            });
80
-        });
81
-    }
82
-
83
-    /**
84
-     * {@inheritDoc}
85
-     * @see \Fisharebest\Webtrees\Module\ModuleCustomInterface::customModuleVersion()
86
-     */
87
-    public function customModuleVersion(): string
88
-    {
89
-        return '2.0.11-v.1';
90
-    }
91
-
92
-    /**
93
-     * {@inheritDoc}
94
-     * @see \Fisharebest\Webtrees\Module\ModuleListInterface::listUrl()
95
-     */
96
-    public function listUrl(Tree $tree, array $parameters = []): string
97
-    {
98
-        $surname = $parameters['surname'] ?? '';
99
-
100
-        $xref = app(ServerRequestInterface::class)->getAttribute('xref', '');
101
-        if ($xref !== '' && ($individual = Registry::individualFactory()->make($xref, $tree)) !== null) {
102
-            $surname = $individual->getAllNames()[$individual->getPrimaryName()]['surname'];
103
-        }
104
-
105
-        if ($surname !== '') {
106
-            return route(LineagesPage::class, [
107
-                'tree'      =>  $tree->name(),
108
-                'surname'   =>  $surname
109
-            ] + $parameters);
110
-        }
111
-        return route(SurnamesList::class, [
112
-            'tree'  =>  $tree->name()
113
-        ] + $parameters);
114
-    }
115
-
116
-    /**
117
-     * {@inheritDoc}
118
-     * @see \Fisharebest\Webtrees\Module\ModuleListInterface::listMenuClass()
119
-     */
120
-    public function listMenuClass(): string
121
-    {
122
-        return 'menu-maj-patrolineage';
123
-    }
124
-
125
-    /**
126
-     * {@inheritDoc}
127
-     * @see \Fisharebest\Webtrees\Module\ModuleGlobalInterface::headContent()
128
-     */
129
-    public function headContent(): string
130
-    {
131
-        return '<link rel="stylesheet" href="' . e($this->moduleCssUrl()) . '">';
132
-    }
41
+	use ModuleMyArtJaubTrait;
42
+	use ModuleListTrait;
43
+	use ModuleGlobalTrait;
44
+
45
+	 /**
46
+	  * {@inheritDoc}
47
+	  * @see \Fisharebest\Webtrees\Module\AbstractModule::title()
48
+	  */
49
+	public function title(): string
50
+	{
51
+		return /* I18N: Name of the “Patronymic lineage” module */ I18N::translate('Patronymic Lineages');
52
+	}
53
+
54
+	/**
55
+	 * {@inheritDoc}
56
+	 * @see \Fisharebest\Webtrees\Module\AbstractModule::description()
57
+	 */
58
+	public function description(): string
59
+	{
60
+		//phpcs:ignore Generic.Files.LineLength.TooLong
61
+		return /* I18N: Description of the “Patronymic lineage” module */ I18N::translate('Display lineages of people holding the same surname.');
62
+	}
63
+
64
+	/**
65
+	 * {@inheritDoc}
66
+	 * @see \MyArtJaub\Webtrees\Module\ModuleMyArtJaubInterface::loadRoutes()
67
+	 */
68
+	public function loadRoutes(Map $router): void
69
+	{
70
+		$router->attach('', '', static function (Map $router): void {
71
+
72
+			$router->attach('', '/module-maj/lineages', static function (Map $router): void {
73
+
74
+				$router->attach('', '/Page', static function (Map $router): void {
75
+
76
+					$router->get(SurnamesList::class, '/{tree}/list{/alpha}', SurnamesList::class);
77
+					$router->get(LineagesPage::class, '/{tree}/lineage/{surname}', LineagesPage::class);
78
+				});
79
+			});
80
+		});
81
+	}
82
+
83
+	/**
84
+	 * {@inheritDoc}
85
+	 * @see \Fisharebest\Webtrees\Module\ModuleCustomInterface::customModuleVersion()
86
+	 */
87
+	public function customModuleVersion(): string
88
+	{
89
+		return '2.0.11-v.1';
90
+	}
91
+
92
+	/**
93
+	 * {@inheritDoc}
94
+	 * @see \Fisharebest\Webtrees\Module\ModuleListInterface::listUrl()
95
+	 */
96
+	public function listUrl(Tree $tree, array $parameters = []): string
97
+	{
98
+		$surname = $parameters['surname'] ?? '';
99
+
100
+		$xref = app(ServerRequestInterface::class)->getAttribute('xref', '');
101
+		if ($xref !== '' && ($individual = Registry::individualFactory()->make($xref, $tree)) !== null) {
102
+			$surname = $individual->getAllNames()[$individual->getPrimaryName()]['surname'];
103
+		}
104
+
105
+		if ($surname !== '') {
106
+			return route(LineagesPage::class, [
107
+				'tree'      =>  $tree->name(),
108
+				'surname'   =>  $surname
109
+			] + $parameters);
110
+		}
111
+		return route(SurnamesList::class, [
112
+			'tree'  =>  $tree->name()
113
+		] + $parameters);
114
+	}
115
+
116
+	/**
117
+	 * {@inheritDoc}
118
+	 * @see \Fisharebest\Webtrees\Module\ModuleListInterface::listMenuClass()
119
+	 */
120
+	public function listMenuClass(): string
121
+	{
122
+		return 'menu-maj-patrolineage';
123
+	}
124
+
125
+	/**
126
+	 * {@inheritDoc}
127
+	 * @see \Fisharebest\Webtrees\Module\ModuleGlobalInterface::headContent()
128
+	 */
129
+	public function headContent(): string
130
+	{
131
+		return '<link rel="stylesheet" href="' . e($this->moduleCssUrl()) . '">';
132
+	}
133 133
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -61,11 +61,11 @@  discard block
 block discarded – undo
61 61
      */
62 62
     public function loadRoutes(Map $router): void
63 63
     {
64
-        $router->attach('', '', static function (Map $router): void {
64
+        $router->attach('', '', static function(Map $router): void {
65 65
 
66
-            $router->attach('', '/module-maj/lineages', static function (Map $router): void {
66
+            $router->attach('', '/module-maj/lineages', static function(Map $router): void {
67 67
 
68
-                $router->attach('', '/Page', static function (Map $router): void {
68
+                $router->attach('', '/Page', static function(Map $router): void {
69 69
 
70 70
                     $router->get(SurnamesList::class, '/{tree}/list{/alpha}', SurnamesList::class);
71 71
                     $router->get(LineagesPage::class, '/{tree}/lineage/{surname}', LineagesPage::class);
@@ -122,6 +122,6 @@  discard block
 block discarded – undo
122 122
      */
123 123
     public function headContent(): string
124 124
     {
125
-        return '<link rel="stylesheet" href="' . e($this->moduleCssUrl()) . '">';
125
+        return '<link rel="stylesheet" href="'.e($this->moduleCssUrl()).'">';
126 126
     }
127 127
 }
Please login to merge, or discard this patch.
app/Module/PatronymicLineage/Http/RequestHandlers/LineagesPage.php 2 patches
Indentation   +65 added lines, -65 removed lines patch added patch discarded remove patch
@@ -31,69 +31,69 @@
 block discarded – undo
31 31
  */
32 32
 class LineagesPage implements RequestHandlerInterface
33 33
 {
34
-    use ViewResponseTrait;
35
-
36
-    /**
37
-     * @var PatronymicLineageModule|null $module
38
-     */
39
-    private $module;
40
-
41
-    /**
42
-     * @var IndividualListModule|null $indilist_module
43
-     */
44
-    private $indilist_module;
45
-
46
-    /**
47
-     * Constructor for LineagesPage Request handler
48
-     *
49
-     * @param ModuleService $module_service
50
-     */
51
-    public function __construct(ModuleService $module_service)
52
-    {
53
-        $this->module = $module_service->findByInterface(PatronymicLineageModule::class)->first();
54
-        $this->indilist_module = $module_service->findByInterface(IndividualListModule::class)->first();
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
-        if ($this->indilist_module === null) {
68
-            throw new HttpNotFoundException(I18N::translate('There is no module to handle individual lists.'));
69
-        }
70
-
71
-        $tree = $request->getAttribute('tree');
72
-        assert($tree instanceof Tree);
73
-
74
-        $surname = $request->getAttribute('surname');
75
-
76
-        $initial = mb_substr($surname, 0, 1);
77
-        $initials_list = collect($this->indilist_module->surnameAlpha($tree, false, false, I18N::locale()))
78
-            ->reject(function (int $count, string $initial): bool {
79
-
80
-                return $initial === '@' || $initial === ',';
81
-            });
82
-
83
-        $title = I18N::translate('Patronymic Lineages') . ' — ' . $surname;
84
-
85
-        $lineages = app()->make(LineageBuilder::class, ['surname' => $surname])->buildLineages();
86
-
87
-        return $this->viewResponse($this->module->name() . '::lineages-page', [
88
-            'title'         =>  $title,
89
-            'module'        =>  $this->module,
90
-            'tree'          =>  $tree,
91
-            'initials_list' =>  $initials_list,
92
-            'initial'       =>  $initial,
93
-            'show_all'      =>  'no',
94
-            'surname'       =>  $surname,
95
-            'lineages'      =>  $lineages,
96
-            'nb_lineages'   =>  $lineages !== null ? $lineages->count() : 0
97
-        ]);
98
-    }
34
+	use ViewResponseTrait;
35
+
36
+	/**
37
+	 * @var PatronymicLineageModule|null $module
38
+	 */
39
+	private $module;
40
+
41
+	/**
42
+	 * @var IndividualListModule|null $indilist_module
43
+	 */
44
+	private $indilist_module;
45
+
46
+	/**
47
+	 * Constructor for LineagesPage Request handler
48
+	 *
49
+	 * @param ModuleService $module_service
50
+	 */
51
+	public function __construct(ModuleService $module_service)
52
+	{
53
+		$this->module = $module_service->findByInterface(PatronymicLineageModule::class)->first();
54
+		$this->indilist_module = $module_service->findByInterface(IndividualListModule::class)->first();
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
+		if ($this->indilist_module === null) {
68
+			throw new HttpNotFoundException(I18N::translate('There is no module to handle individual lists.'));
69
+		}
70
+
71
+		$tree = $request->getAttribute('tree');
72
+		assert($tree instanceof Tree);
73
+
74
+		$surname = $request->getAttribute('surname');
75
+
76
+		$initial = mb_substr($surname, 0, 1);
77
+		$initials_list = collect($this->indilist_module->surnameAlpha($tree, false, false, I18N::locale()))
78
+			->reject(function (int $count, string $initial): bool {
79
+
80
+				return $initial === '@' || $initial === ',';
81
+			});
82
+
83
+		$title = I18N::translate('Patronymic Lineages') . ' — ' . $surname;
84
+
85
+		$lineages = app()->make(LineageBuilder::class, ['surname' => $surname])->buildLineages();
86
+
87
+		return $this->viewResponse($this->module->name() . '::lineages-page', [
88
+			'title'         =>  $title,
89
+			'module'        =>  $this->module,
90
+			'tree'          =>  $tree,
91
+			'initials_list' =>  $initials_list,
92
+			'initial'       =>  $initial,
93
+			'show_all'      =>  'no',
94
+			'surname'       =>  $surname,
95
+			'lineages'      =>  $lineages,
96
+			'nb_lineages'   =>  $lineages !== null ? $lineages->count() : 0
97
+		]);
98
+	}
99 99
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -75,16 +75,16 @@
 block discarded – undo
75 75
 
76 76
         $initial = mb_substr($surname, 0, 1);
77 77
         $initials_list = collect($this->indilist_module->surnameAlpha($tree, false, false, I18N::locale()))
78
-            ->reject(function (int $count, string $initial): bool {
78
+            ->reject(function(int $count, string $initial): bool {
79 79
 
80 80
                 return $initial === '@' || $initial === ',';
81 81
             });
82 82
 
83
-        $title = I18N::translate('Patronymic Lineages') . ' — ' . $surname;
83
+        $title = I18N::translate('Patronymic Lineages').' — '.$surname;
84 84
 
85 85
         $lineages = app()->make(LineageBuilder::class, ['surname' => $surname])->buildLineages();
86 86
 
87
-        return $this->viewResponse($this->module->name() . '::lineages-page', [
87
+        return $this->viewResponse($this->module->name().'::lineages-page', [
88 88
             'title'         =>  $title,
89 89
             'module'        =>  $this->module,
90 90
             'tree'          =>  $tree,
Please login to merge, or discard this patch.
app/Module/PatronymicLineage/Http/RequestHandlers/SurnamesList.php 2 patches
Indentation   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -30,74 +30,74 @@
 block discarded – undo
30 30
  */
31 31
 class SurnamesList implements RequestHandlerInterface
32 32
 {
33
-    use ViewResponseTrait;
34
-
35
-    /**
36
-     * @var PatronymicLineageModule|null $module
37
-     */
38
-    private $module;
39
-
40
-    /**
41
-     * @var IndividualListModule|null $indilist_module
42
-     */
43
-    private $indilist_module;
44
-
45
-    /**
46
-     * Constructor for SurnamesList Request Handler
47
-     *
48
-     * @param ModuleService $module_service
49
-     */
50
-    public function __construct(ModuleService $module_service)
51
-    {
52
-        $this->module = $module_service->findByInterface(PatronymicLineageModule::class)->first();
53
-        $this->indilist_module = $module_service->findByInterface(IndividualListModule::class)->first();
54
-    }
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
-        }
65
-
66
-        if ($this->indilist_module === null) {
67
-            throw new HttpNotFoundException(I18N::translate('There is no module to handle individual lists.'));
68
-        }
69
-
70
-        $tree = $request->getAttribute('tree');
71
-        assert($tree instanceof Tree);
72
-
73
-        $initial = $request->getAttribute('alpha');
74
-        $initials_list = collect($this->indilist_module->surnameAlpha($tree, false, false, I18N::locale()))
75
-            ->reject(function (int $count, string $initial): bool {
76
-
77
-                return $initial === '@' || $initial === ',';
78
-            });
79
-
80
-        $show_all = $request->getQueryParams()['show_all'] ?? 'no';
81
-
82
-        if ($show_all === 'yes') {
83
-            $title = I18N::translate('Patronymic Lineages') . ' — ' . I18N::translate('All');
84
-            $surnames = $this->indilist_module->surnames($tree, '', '', false, false, I18N::locale());
85
-        } elseif ($initial !== null && mb_strlen($initial) == 1) {
86
-            $title = I18N::translate('Patronymic Lineages') . ' — ' . $initial;
87
-            $surnames = $this->indilist_module->surnames($tree, '', $initial, false, false, I18N::locale());
88
-        } else {
89
-            $title =  I18N::translate('Patronymic Lineages');
90
-            $surnames = [];
91
-        }
92
-
93
-        return $this->viewResponse($this->module->name() . '::surnames-page', [
94
-            'title'         =>  $title,
95
-            'module'        =>  $this->module,
96
-            'tree'          =>  $tree,
97
-            'initials_list' =>  $initials_list,
98
-            'initial'       =>  $initial,
99
-            'show_all'      =>  $show_all,
100
-            'surnames'      =>  $surnames
101
-        ]);
102
-    }
33
+	use ViewResponseTrait;
34
+
35
+	/**
36
+	 * @var PatronymicLineageModule|null $module
37
+	 */
38
+	private $module;
39
+
40
+	/**
41
+	 * @var IndividualListModule|null $indilist_module
42
+	 */
43
+	private $indilist_module;
44
+
45
+	/**
46
+	 * Constructor for SurnamesList Request Handler
47
+	 *
48
+	 * @param ModuleService $module_service
49
+	 */
50
+	public function __construct(ModuleService $module_service)
51
+	{
52
+		$this->module = $module_service->findByInterface(PatronymicLineageModule::class)->first();
53
+		$this->indilist_module = $module_service->findByInterface(IndividualListModule::class)->first();
54
+	}
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
+		}
65
+
66
+		if ($this->indilist_module === null) {
67
+			throw new HttpNotFoundException(I18N::translate('There is no module to handle individual lists.'));
68
+		}
69
+
70
+		$tree = $request->getAttribute('tree');
71
+		assert($tree instanceof Tree);
72
+
73
+		$initial = $request->getAttribute('alpha');
74
+		$initials_list = collect($this->indilist_module->surnameAlpha($tree, false, false, I18N::locale()))
75
+			->reject(function (int $count, string $initial): bool {
76
+
77
+				return $initial === '@' || $initial === ',';
78
+			});
79
+
80
+		$show_all = $request->getQueryParams()['show_all'] ?? 'no';
81
+
82
+		if ($show_all === 'yes') {
83
+			$title = I18N::translate('Patronymic Lineages') . ' — ' . I18N::translate('All');
84
+			$surnames = $this->indilist_module->surnames($tree, '', '', false, false, I18N::locale());
85
+		} elseif ($initial !== null && mb_strlen($initial) == 1) {
86
+			$title = I18N::translate('Patronymic Lineages') . ' — ' . $initial;
87
+			$surnames = $this->indilist_module->surnames($tree, '', $initial, false, false, I18N::locale());
88
+		} else {
89
+			$title =  I18N::translate('Patronymic Lineages');
90
+			$surnames = [];
91
+		}
92
+
93
+		return $this->viewResponse($this->module->name() . '::surnames-page', [
94
+			'title'         =>  $title,
95
+			'module'        =>  $this->module,
96
+			'tree'          =>  $tree,
97
+			'initials_list' =>  $initials_list,
98
+			'initial'       =>  $initial,
99
+			'show_all'      =>  $show_all,
100
+			'surnames'      =>  $surnames
101
+		]);
102
+	}
103 103
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 
73 73
         $initial = $request->getAttribute('alpha');
74 74
         $initials_list = collect($this->indilist_module->surnameAlpha($tree, false, false, I18N::locale()))
75
-            ->reject(function (int $count, string $initial): bool {
75
+            ->reject(function(int $count, string $initial): bool {
76 76
 
77 77
                 return $initial === '@' || $initial === ',';
78 78
             });
@@ -80,17 +80,17 @@  discard block
 block discarded – undo
80 80
         $show_all = $request->getQueryParams()['show_all'] ?? 'no';
81 81
 
82 82
         if ($show_all === 'yes') {
83
-            $title = I18N::translate('Patronymic Lineages') . ' — ' . I18N::translate('All');
83
+            $title = I18N::translate('Patronymic Lineages').' — '.I18N::translate('All');
84 84
             $surnames = $this->indilist_module->surnames($tree, '', '', false, false, I18N::locale());
85 85
         } elseif ($initial !== null && mb_strlen($initial) == 1) {
86
-            $title = I18N::translate('Patronymic Lineages') . ' — ' . $initial;
86
+            $title = I18N::translate('Patronymic Lineages').' — '.$initial;
87 87
             $surnames = $this->indilist_module->surnames($tree, '', $initial, false, false, I18N::locale());
88 88
         } else {
89
-            $title =  I18N::translate('Patronymic Lineages');
89
+            $title = I18N::translate('Patronymic Lineages');
90 90
             $surnames = [];
91 91
         }
92 92
 
93
-        return $this->viewResponse($this->module->name() . '::surnames-page', [
93
+        return $this->viewResponse($this->module->name().'::surnames-page', [
94 94
             'title'         =>  $title,
95 95
             'module'        =>  $this->module,
96 96
             'tree'          =>  $tree,
Please login to merge, or discard this patch.
app/Module/PatronymicLineage/Model/LineageNode.php 2 patches
Indentation   +113 added lines, -113 removed lines patch added patch discarded remove patch
@@ -25,117 +25,117 @@
 block discarded – undo
25 25
 class LineageNode
26 26
 {
27 27
 
28
-    /**
29
-     * @var Collection $linked_fams Spouse families linked to the node
30
-     */
31
-    private $linked_fams;
32
-
33
-    /**
34
-     * @var ?Individual $node_indi Reference individual for the node
35
-     */
36
-    private $node_indi;
37
-
38
-    /**
39
-     * @var LineageRootNode $root_node Root node of the lineage
40
-     */
41
-    private $root_node;
42
-
43
-    /**
44
-     * @var ?string $alt_surname Linked surname, used to link to another lineage
45
-     */
46
-    private $alt_surname;
47
-
48
-    /**
49
-     * Constructor for Lineage node
50
-     *
51
-     * @param Individual $node_indi Main individual
52
-     * @param LineageRootNode $root_node Node of the lineage root
53
-     * @param null|string $alt_surname Follow-up surname
54
-     */
55
-    public function __construct(?Individual $node_indi = null, LineageRootNode $root_node, $alt_surname = null)
56
-    {
57
-        $this->node_indi = $node_indi;
58
-        $this->root_node = $root_node;
59
-        $this->alt_surname = $alt_surname;
60
-        $this->linked_fams = new Collection();
61
-    }
62
-
63
-    /**
64
-     * Add a spouse family to the node
65
-     *
66
-     * @param Family $fams
67
-     * @return stdClass
68
-     */
69
-    public function addFamily(Family $fams): object
70
-    {
71
-        if (!$this->linked_fams->has($fams->xref())) {
72
-            $this->linked_fams->put($fams->xref(), (object) [
73
-                'family'   =>  $fams,
74
-                'children' =>  new Collection()
75
-            ]);
76
-        }
77
-        return $this->linked_fams->get($fams->xref());
78
-    }
79
-
80
-    /**
81
-     * Add a child LineageNode to the node
82
-     *
83
-     * @param Family $fams
84
-     * @param LineageNode $child
85
-     */
86
-    public function addChild(Family $fams, LineageNode $child = null): void
87
-    {
88
-        $this->addFamily($fams)->children->push($child);
89
-        $this->root_node->incrementChildNodes();
90
-    }
91
-
92
-    /**
93
-     * Returns the node individual
94
-     *
95
-     * @return Individual|NULL
96
-     */
97
-    public function individual(): ?Individual
98
-    {
99
-        return $this->node_indi;
100
-    }
101
-
102
-    /**
103
-     * Returns the lineage root node individual
104
-     *
105
-     * @return LineageRootNode
106
-     */
107
-    public function rootNode(): LineageRootNode
108
-    {
109
-        return $this->root_node;
110
-    }
111
-
112
-    /**
113
-     * Returns the spouse families linked to the node
114
-     *
115
-     * @return Collection<string, \stdClass>
116
-     */
117
-    public function families(): Collection
118
-    {
119
-        return $this->linked_fams;
120
-    }
121
-
122
-    /**
123
-     * Returns the follow-up surname
124
-     *
125
-     * @return string
126
-     */
127
-    public function followUpSurname(): string
128
-    {
129
-        return $this->alt_surname ?? '';
130
-    }
131
-
132
-    /**
133
-     * Indicates whether the node has a follow up surname
134
-     *
135
-     * @return boolean
136
-     */
137
-    public function hasFollowUpSurname(): bool
138
-    {
139
-        return mb_strlen($this->followUpSurname()) > 0 ;
140
-    }
28
+	/**
29
+	 * @var Collection $linked_fams Spouse families linked to the node
30
+	 */
31
+	private $linked_fams;
32
+
33
+	/**
34
+	 * @var ?Individual $node_indi Reference individual for the node
35
+	 */
36
+	private $node_indi;
37
+
38
+	/**
39
+	 * @var LineageRootNode $root_node Root node of the lineage
40
+	 */
41
+	private $root_node;
42
+
43
+	/**
44
+	 * @var ?string $alt_surname Linked surname, used to link to another lineage
45
+	 */
46
+	private $alt_surname;
47
+
48
+	/**
49
+	 * Constructor for Lineage node
50
+	 *
51
+	 * @param Individual $node_indi Main individual
52
+	 * @param LineageRootNode $root_node Node of the lineage root
53
+	 * @param null|string $alt_surname Follow-up surname
54
+	 */
55
+	public function __construct(?Individual $node_indi = null, LineageRootNode $root_node, $alt_surname = null)
56
+	{
57
+		$this->node_indi = $node_indi;
58
+		$this->root_node = $root_node;
59
+		$this->alt_surname = $alt_surname;
60
+		$this->linked_fams = new Collection();
61
+	}
62
+
63
+	/**
64
+	 * Add a spouse family to the node
65
+	 *
66
+	 * @param Family $fams
67
+	 * @return stdClass
68
+	 */
69
+	public function addFamily(Family $fams): object
70
+	{
71
+		if (!$this->linked_fams->has($fams->xref())) {
72
+			$this->linked_fams->put($fams->xref(), (object) [
73
+				'family'   =>  $fams,
74
+				'children' =>  new Collection()
75
+			]);
76
+		}
77
+		return $this->linked_fams->get($fams->xref());
78
+	}
79
+
80
+	/**
81
+	 * Add a child LineageNode to the node
82
+	 *
83
+	 * @param Family $fams
84
+	 * @param LineageNode $child
85
+	 */
86
+	public function addChild(Family $fams, LineageNode $child = null): void
87
+	{
88
+		$this->addFamily($fams)->children->push($child);
89
+		$this->root_node->incrementChildNodes();
90
+	}
91
+
92
+	/**
93
+	 * Returns the node individual
94
+	 *
95
+	 * @return Individual|NULL
96
+	 */
97
+	public function individual(): ?Individual
98
+	{
99
+		return $this->node_indi;
100
+	}
101
+
102
+	/**
103
+	 * Returns the lineage root node individual
104
+	 *
105
+	 * @return LineageRootNode
106
+	 */
107
+	public function rootNode(): LineageRootNode
108
+	{
109
+		return $this->root_node;
110
+	}
111
+
112
+	/**
113
+	 * Returns the spouse families linked to the node
114
+	 *
115
+	 * @return Collection<string, \stdClass>
116
+	 */
117
+	public function families(): Collection
118
+	{
119
+		return $this->linked_fams;
120
+	}
121
+
122
+	/**
123
+	 * Returns the follow-up surname
124
+	 *
125
+	 * @return string
126
+	 */
127
+	public function followUpSurname(): string
128
+	{
129
+		return $this->alt_surname ?? '';
130
+	}
131
+
132
+	/**
133
+	 * Indicates whether the node has a follow up surname
134
+	 *
135
+	 * @return boolean
136
+	 */
137
+	public function hasFollowUpSurname(): bool
138
+	{
139
+		return mb_strlen($this->followUpSurname()) > 0 ;
140
+	}
141 141
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
     public function addFamily(Family $fams): object
69 69
     {
70 70
         if (!$this->linked_fams->has($fams->xref())) {
71
-            $this->linked_fams->put($fams->xref(), (object) [
71
+            $this->linked_fams->put($fams->xref(), (object)[
72 72
                 'family'   =>  $fams,
73 73
                 'children' =>  new Collection()
74 74
             ]);
@@ -135,6 +135,6 @@  discard block
 block discarded – undo
135 135
      */
136 136
     public function hasFollowUpSurname(): bool
137 137
     {
138
-        return mb_strlen($this->followUpSurname()) > 0 ;
138
+        return mb_strlen($this->followUpSurname()) > 0;
139 139
     }
140 140
 }
Please login to merge, or discard this patch.
app/Module/PatronymicLineage/Model/LineageRootNode.php 1 patch
Indentation   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -24,68 +24,68 @@
 block discarded – undo
24 24
 class LineageRootNode extends LineageNode
25 25
 {
26 26
 
27
-    /**
28
-     * @var Collection<string, int> $places Places for the lineage node
29
-     */
30
-    private $places;
27
+	/**
28
+	 * @var Collection<string, int> $places Places for the lineage node
29
+	 */
30
+	private $places;
31 31
 
32
-    /**
33
-     * @var int $nb_children Number of node childs
34
-     */
35
-    private $nb_children;
32
+	/**
33
+	 * @var int $nb_children Number of node childs
34
+	 */
35
+	private $nb_children;
36 36
 
37
-    /**
38
-     * Constructor for LineageRootNode
39
-     *
40
-     * @param Individual|null $node_indi
41
-     */
42
-    public function __construct(?Individual $node_indi = null)
43
-    {
44
-        parent::__construct($node_indi, $this);
45
-        $this->places = new Collection();
46
-        $this->nb_children = 0;
47
-    }
37
+	/**
38
+	 * Constructor for LineageRootNode
39
+	 *
40
+	 * @param Individual|null $node_indi
41
+	 */
42
+	public function __construct(?Individual $node_indi = null)
43
+	{
44
+		parent::__construct($node_indi, $this);
45
+		$this->places = new Collection();
46
+		$this->nb_children = 0;
47
+	}
48 48
 
49
-    /**
50
-     * Adds a place to the list of lineage's place
51
-     *
52
-     * @param Place $place
53
-     */
54
-    public function addPlace(Place $place): void
55
-    {
56
-        $place_name = $place->gedcomName();
57
-        if (mb_strlen($place_name) > 0) {
58
-            $this->places->put($place_name, $this->places->get($place_name, 0) + 1);
59
-        }
60
-    }
49
+	/**
50
+	 * Adds a place to the list of lineage's place
51
+	 *
52
+	 * @param Place $place
53
+	 */
54
+	public function addPlace(Place $place): void
55
+	{
56
+		$place_name = $place->gedcomName();
57
+		if (mb_strlen($place_name) > 0) {
58
+			$this->places->put($place_name, $this->places->get($place_name, 0) + 1);
59
+		}
60
+	}
61 61
 
62
-    /**
63
-     * Returns the number of child nodes.
64
-     * This number is more to be used as indication rather than an accurate one.
65
-     *
66
-     * @return int
67
-     */
68
-    public function numberChildNodes(): int
69
-    {
70
-        return $this->nb_children;
71
-    }
62
+	/**
63
+	 * Returns the number of child nodes.
64
+	 * This number is more to be used as indication rather than an accurate one.
65
+	 *
66
+	 * @return int
67
+	 */
68
+	public function numberChildNodes(): int
69
+	{
70
+		return $this->nb_children;
71
+	}
72 72
 
73
-    /**
74
-     * Increments the number of child nodes by one
75
-     *
76
-     */
77
-    public function incrementChildNodes(): void
78
-    {
79
-        $this->nb_children++;
80
-    }
73
+	/**
74
+	 * Increments the number of child nodes by one
75
+	 *
76
+	 */
77
+	public function incrementChildNodes(): void
78
+	{
79
+		$this->nb_children++;
80
+	}
81 81
 
82
-    /**
83
-     * Returns the list of place for the lineage
84
-     *
85
-     * @return Collection<string, int>
86
-     */
87
-    public function places(): Collection
88
-    {
89
-        return $this->places;
90
-    }
82
+	/**
83
+	 * Returns the list of place for the lineage
84
+	 *
85
+	 * @return Collection<string, int>
86
+	 */
87
+	public function places(): Collection
88
+	{
89
+		return $this->places;
90
+	}
91 91
 }
Please login to merge, or discard this patch.