Passed
Push — main ( 4197a4...465e30 )
by Jonathan
05:10
created
app/Module/MiscExtensions/Http/RequestHandlers/AdminConfigAction.php 1 patch
Indentation   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -27,43 +27,43 @@
 block discarded – undo
27 27
  */
28 28
 class AdminConfigAction implements RequestHandlerInterface
29 29
 {
30
-    private ?MiscExtensionsModule $module;
30
+	private ?MiscExtensionsModule $module;
31 31
 
32
-    /**
33
-     * Constructor for AdminConfigPage Request Handler
34
-     *
35
-     * @param ModuleService $module_service
36
-     */
37
-    public function __construct(ModuleService $module_service)
38
-    {
39
-        $this->module = $module_service->findByInterface(MiscExtensionsModule::class)->first();
40
-    }
32
+	/**
33
+	 * Constructor for AdminConfigPage Request Handler
34
+	 *
35
+	 * @param ModuleService $module_service
36
+	 */
37
+	public function __construct(ModuleService $module_service)
38
+	{
39
+		$this->module = $module_service->findByInterface(MiscExtensionsModule::class)->first();
40
+	}
41 41
 
42
-    /**
43
-     * {@inheritDoc}
44
-     * @see \Psr\Http\Server\RequestHandlerInterface::handle()
45
-     */
46
-    public function handle(ServerRequestInterface $request): ResponseInterface
47
-    {
48
-        if ($this->module === null) {
49
-            FlashMessages::addMessage(
50
-                I18N::translate('The attached module could not be found.'),
51
-                'danger'
52
-            );
53
-            return redirect(route(AdminConfigPage::class));
54
-        }
42
+	/**
43
+	 * {@inheritDoc}
44
+	 * @see \Psr\Http\Server\RequestHandlerInterface::handle()
45
+	 */
46
+	public function handle(ServerRequestInterface $request): ResponseInterface
47
+	{
48
+		if ($this->module === null) {
49
+			FlashMessages::addMessage(
50
+				I18N::translate('The attached module could not be found.'),
51
+				'danger'
52
+			);
53
+			return redirect(route(AdminConfigPage::class));
54
+		}
55 55
 
56
-        $params = (array) $request->getParsedBody();
56
+		$params = (array) $request->getParsedBody();
57 57
 
58
-        $this->module->setPreference('MAJ_TITLE_PREFIX', $params['MAJ_TITLE_PREFIX'] ?? '');
59
-        $this->module->setPreference('MAJ_DISPLAY_CNIL', $params['MAJ_DISPLAY_CNIL'] ?? '');
60
-        $this->module->setPreference('MAJ_CNIL_REFERENCE', $params['MAJ_CNIL_REFERENCE' ?? '']);
58
+		$this->module->setPreference('MAJ_TITLE_PREFIX', $params['MAJ_TITLE_PREFIX'] ?? '');
59
+		$this->module->setPreference('MAJ_DISPLAY_CNIL', $params['MAJ_DISPLAY_CNIL'] ?? '');
60
+		$this->module->setPreference('MAJ_CNIL_REFERENCE', $params['MAJ_CNIL_REFERENCE' ?? '']);
61 61
 
62
-        FlashMessages::addMessage(
63
-            I18N::translate('The preferences for the module “%s” have been updated.', $this->module->title()),
64
-            'success'
65
-        );
62
+		FlashMessages::addMessage(
63
+			I18N::translate('The preferences for the module “%s” have been updated.', $this->module->title()),
64
+			'success'
65
+		);
66 66
 
67
-        return redirect(route(AdminConfigPage::class));
68
-    }
67
+		return redirect(route(AdminConfigPage::class));
68
+	}
69 69
 }
Please login to merge, or discard this patch.
app/Module/MiscExtensions/Http/RequestHandlers/AdminConfigPage.php 1 patch
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.
app/Module/MiscExtensions/MiscExtensionsModule.php 1 patch
Indentation   +74 added lines, -74 removed lines patch added patch discarded remove patch
@@ -32,89 +32,89 @@
 block discarded – undo
32 32
  * Provide miscellaneous improvements to webtrees.
33 33
  */
34 34
 class MiscExtensionsModule extends AbstractModule implements
35
-    ModuleMyArtJaubInterface,
36
-    ModuleConfigInterface,
37
-    ModuleHookSubscriberInterface
35
+	ModuleMyArtJaubInterface,
36
+	ModuleConfigInterface,
37
+	ModuleHookSubscriberInterface
38 38
 {
39
-    use ModuleMyArtJaubTrait {
40
-        boot as traitBoot;
41
-    }
42
-    use ModuleConfigTrait;
39
+	use ModuleMyArtJaubTrait {
40
+		boot as traitBoot;
41
+	}
42
+	use ModuleConfigTrait;
43 43
 
44
-    /**
45
-     * {@inheritDoc}
46
-     * @see \Fisharebest\Webtrees\Module\AbstractModule::title()
47
-     */
48
-    public function title(): string
49
-    {
50
-        return /* I18N: Name of the “MiscExtensions” module */ I18N::translate('Miscellaneous extensions');
51
-    }
44
+	/**
45
+	 * {@inheritDoc}
46
+	 * @see \Fisharebest\Webtrees\Module\AbstractModule::title()
47
+	 */
48
+	public function title(): string
49
+	{
50
+		return /* I18N: Name of the “MiscExtensions” module */ I18N::translate('Miscellaneous extensions');
51
+	}
52 52
 
53
-    /**
54
-     * {@inheritDoc}
55
-     * @see \Fisharebest\Webtrees\Module\AbstractModule::description()
56
-     */
57
-    public function description(): string
58
-    {
59
-        //phpcs:ignore Generic.Files.LineLength.TooLong
60
-        return /* I18N: Description of the “MiscExtensions” module */ I18N::translate('Miscellaneous extensions for webtrees.');
61
-    }
53
+	/**
54
+	 * {@inheritDoc}
55
+	 * @see \Fisharebest\Webtrees\Module\AbstractModule::description()
56
+	 */
57
+	public function description(): string
58
+	{
59
+		//phpcs:ignore Generic.Files.LineLength.TooLong
60
+		return /* I18N: Description of the “MiscExtensions” module */ I18N::translate('Miscellaneous extensions for webtrees.');
61
+	}
62 62
 
63
-    /**
64
-     * {@inheritDoc}
65
-     * @see \Fisharebest\Webtrees\Module\AbstractModule::boot()
66
-     */
67
-    public function boot(): void
68
-    {
69
-        $this->traitBoot();
70
-        View::registerCustomView('::modules/privacy-policy/page', $this->name() . '::privacy-policy');
71
-    }
63
+	/**
64
+	 * {@inheritDoc}
65
+	 * @see \Fisharebest\Webtrees\Module\AbstractModule::boot()
66
+	 */
67
+	public function boot(): void
68
+	{
69
+		$this->traitBoot();
70
+		View::registerCustomView('::modules/privacy-policy/page', $this->name() . '::privacy-policy');
71
+	}
72 72
 
73
-    /**
74
-     * {@inheritDoc}
75
-     * @see \MyArtJaub\Webtrees\Module\ModuleMyArtJaubInterface::loadRoutes()
76
-     */
77
-    public function loadRoutes(Map $router): void
78
-    {
79
-        $router->attach('', '', static function (Map $router): void {
73
+	/**
74
+	 * {@inheritDoc}
75
+	 * @see \MyArtJaub\Webtrees\Module\ModuleMyArtJaubInterface::loadRoutes()
76
+	 */
77
+	public function loadRoutes(Map $router): void
78
+	{
79
+		$router->attach('', '', static function (Map $router): void {
80 80
 
81
-            $router->attach('', '/module-maj/misc', static function (Map $router): void {
81
+			$router->attach('', '/module-maj/misc', static function (Map $router): void {
82 82
 
83
-                $router->attach('', '/config/admin', static function (Map $router): void {
83
+				$router->attach('', '/config/admin', static function (Map $router): void {
84 84
 
85
-                    $router->get(AdminConfigPage::class, '', AdminConfigPage::class);
86
-                    $router->post(AdminConfigAction::class, '', AdminConfigAction::class);
87
-                });
88
-            });
89
-        });
90
-    }
85
+					$router->get(AdminConfigPage::class, '', AdminConfigPage::class);
86
+					$router->post(AdminConfigAction::class, '', AdminConfigAction::class);
87
+				});
88
+			});
89
+		});
90
+	}
91 91
 
92
-    /**
93
-     * {@inheritDoc}
94
-     * @see \Fisharebest\Webtrees\Module\ModuleCustomInterface::customModuleVersion()
95
-     */
96
-    public function customModuleVersion(): string
97
-    {
98
-        return '2.1.0-v.1';
99
-    }
92
+	/**
93
+	 * {@inheritDoc}
94
+	 * @see \Fisharebest\Webtrees\Module\ModuleCustomInterface::customModuleVersion()
95
+	 */
96
+	public function customModuleVersion(): string
97
+	{
98
+		return '2.1.0-v.1';
99
+	}
100 100
 
101
-    /**
102
-     * {@inheritDoc}
103
-     * @see \Fisharebest\Webtrees\Module\ModuleConfigInterface::getConfigLink()
104
-     */
105
-    public function getConfigLink(): string
106
-    {
107
-        return route(AdminConfigPage::class);
108
-    }
101
+	/**
102
+	 * {@inheritDoc}
103
+	 * @see \Fisharebest\Webtrees\Module\ModuleConfigInterface::getConfigLink()
104
+	 */
105
+	public function getConfigLink(): string
106
+	{
107
+		return route(AdminConfigPage::class);
108
+	}
109 109
 
110
-    /**
111
-     * {@inheritDoc}
112
-     * @see \MyArtJaub\Webtrees\Contracts\Hooks\ModuleHookSubscriberInterface::listSubscribedHooks()
113
-     */
114
-    public function listSubscribedHooks(): array
115
-    {
116
-        return [
117
-            app()->makeWith(TitlesCardHook::class, [ 'module' => $this ])
118
-        ];
119
-    }
110
+	/**
111
+	 * {@inheritDoc}
112
+	 * @see \MyArtJaub\Webtrees\Contracts\Hooks\ModuleHookSubscriberInterface::listSubscribedHooks()
113
+	 */
114
+	public function listSubscribedHooks(): array
115
+	{
116
+		return [
117
+			app()->makeWith(TitlesCardHook::class, [ 'module' => $this ])
118
+		];
119
+	}
120 120
 }
Please login to merge, or discard this patch.
app/Module/Sosa/Hooks/SosaIconHook.php 1 patch
Indentation   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -26,51 +26,51 @@
 block discarded – undo
26 26
  */
27 27
 class SosaIconHook implements RecordNameTextExtenderInterface
28 28
 {
29
-    private ModuleInterface $module;
30
-    private SosaRecordsService $sosa_records_service;
29
+	private ModuleInterface $module;
30
+	private SosaRecordsService $sosa_records_service;
31 31
 
32
-    /**
33
-     * Constructor for SosaIconHook
34
-     *
35
-     * @param ModuleInterface $module
36
-     * @param SosaRecordsService $sosa_records_service
37
-     */
38
-    public function __construct(ModuleInterface $module, SosaRecordsService $sosa_records_service)
39
-    {
40
-        $this->module = $module;
41
-        $this->sosa_records_service = $sosa_records_service;
42
-    }
32
+	/**
33
+	 * Constructor for SosaIconHook
34
+	 *
35
+	 * @param ModuleInterface $module
36
+	 * @param SosaRecordsService $sosa_records_service
37
+	 */
38
+	public function __construct(ModuleInterface $module, SosaRecordsService $sosa_records_service)
39
+	{
40
+		$this->module = $module;
41
+		$this->sosa_records_service = $sosa_records_service;
42
+	}
43 43
 
44
-    /**
45
-     * {@inheritDoc}
46
-     * @see \MyArtJaub\Webtrees\Contracts\Hooks\HookInterface::module()
47
-     */
48
-    public function module(): ModuleInterface
49
-    {
50
-        return $this->module;
51
-    }
44
+	/**
45
+	 * {@inheritDoc}
46
+	 * @see \MyArtJaub\Webtrees\Contracts\Hooks\HookInterface::module()
47
+	 */
48
+	public function module(): ModuleInterface
49
+	{
50
+		return $this->module;
51
+	}
52 52
 
53
-    /**
54
-     * {@inheritDoc}
55
-     * @see \MyArtJaub\Webtrees\Contracts\Hooks\RecordNameTextExtenderInterface::recordNamePrepend()
56
-     */
57
-    public function recordNamePrepend(GedcomRecord $record, bool $use_long = false, string $size = ''): string
58
-    {
59
-        return '';
60
-    }
53
+	/**
54
+	 * {@inheritDoc}
55
+	 * @see \MyArtJaub\Webtrees\Contracts\Hooks\RecordNameTextExtenderInterface::recordNamePrepend()
56
+	 */
57
+	public function recordNamePrepend(GedcomRecord $record, bool $use_long = false, string $size = ''): string
58
+	{
59
+		return '';
60
+	}
61 61
 
62
-    /**
63
-     * {@inheritDoc}
64
-     * @see \MyArtJaub\Webtrees\Contracts\Hooks\RecordNameTextExtenderInterface::recordNameAppend()
65
-     */
66
-    public function recordNameAppend(GedcomRecord $record, bool $use_long = false, string $size = ''): string
67
-    {
68
-        if (
69
-            $record instanceof Individual &&
70
-            $this->sosa_records_service->isSosa($record->tree(), Auth::user(), $record)
71
-        ) {
72
-            return view($this->module->name() . '::icons/sosa', [ 'size_style' => $size ]);
73
-        }
74
-        return '';
75
-    }
62
+	/**
63
+	 * {@inheritDoc}
64
+	 * @see \MyArtJaub\Webtrees\Contracts\Hooks\RecordNameTextExtenderInterface::recordNameAppend()
65
+	 */
66
+	public function recordNameAppend(GedcomRecord $record, bool $use_long = false, string $size = ''): string
67
+	{
68
+		if (
69
+			$record instanceof Individual &&
70
+			$this->sosa_records_service->isSosa($record->tree(), Auth::user(), $record)
71
+		) {
72
+			return view($this->module->name() . '::icons/sosa', [ 'size_style' => $size ]);
73
+		}
74
+		return '';
75
+	}
76 76
 }
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/AncestorsListIndividual.php 1 patch
Indentation   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -35,74 +35,74 @@
 block discarded – undo
35 35
  */
36 36
 class AncestorsListIndividual implements RequestHandlerInterface
37 37
 {
38
-    use ViewResponseTrait;
39
-
40
-    /**
41
-     * @var SosaModule|null $module
42
-     */
43
-    private $module;
44
-
45
-    /**
46
-     * @var SosaRecordsService $sosa_record_service
47
-     */
48
-    private $sosa_record_service;
49
-
50
-    /**
51
-     * Constructor for AncestorsListIndividual Request Handler
52
-     *
53
-     * @param ModuleService $module_service
54
-     * @param SosaRecordsService $sosa_record_service
55
-     */
56
-    public function __construct(
57
-        ModuleService $module_service,
58
-        SosaRecordsService $sosa_record_service
59
-    ) {
60
-        $this->module = $module_service->findByInterface(SosaModule::class)->first();
61
-        $this->sosa_record_service = $sosa_record_service;
62
-    }
63
-
64
-    /**
65
-     * {@inheritDoc}
66
-     * @see \Psr\Http\Server\RequestHandlerInterface::handle()
67
-     */
68
-    public function handle(ServerRequestInterface $request): ResponseInterface
69
-    {
70
-        $this->layout = 'layouts/ajax';
71
-
72
-        if ($this->module === null) {
73
-            throw new HttpNotFoundException(I18N::translate('The attached module could not be found.'));
74
-        }
75
-
76
-        $tree = $request->getAttribute('tree');
77
-        assert($tree instanceof Tree);
78
-
79
-        $user = Auth::check() ? $request->getAttribute('user') : new DefaultUser();
80
-
81
-        $current_gen = (int) ($request->getAttribute('gen') ?? 0);
82
-
83
-        if ($current_gen <= 0) {
84
-            return response('Invalid generation', StatusCodeInterface::STATUS_UNPROCESSABLE_ENTITY);
85
-        }
86
-
87
-        $list_ancestors = $this->sosa_record_service->listAncestorsAtGeneration($tree, $user, $current_gen);
88
-        $nb_ancestors_all = $list_ancestors->count();
89
-
90
-        /** @var \Illuminate\Support\Collection<int, \Fisharebest\Webtrees\Individual> $list_ancestors */
91
-        $list_ancestors = $list_ancestors->mapWithKeys(function (stdClass $value) use ($tree): ?array {
92
-                $indi = Registry::individualFactory()->make($value->majs_i_id, $tree);
93
-                return ($indi !== null && $indi->canShowName()) ? [(int) $value->majs_sosa => $indi] : null;
94
-        })->filter();
95
-
96
-        $nb_ancestors_shown = $list_ancestors->count();
97
-
98
-        return $this->viewResponse($this->module->name() . '::list-ancestors-indi-tab', [
99
-            'module_name'       =>  $this->module->name(),
100
-            'title'             =>  I18N::translate('Sosa Ancestors'),
101
-            'tree'              =>  $tree,
102
-            'list_ancestors'    =>  $list_ancestors,
103
-            'nb_ancestors_all'  =>  $nb_ancestors_all,
104
-            'nb_ancestors_theor' =>  pow(2, $current_gen - 1),
105
-            'nb_ancestors_shown' =>  $nb_ancestors_shown
106
-        ]);
107
-    }
38
+	use ViewResponseTrait;
39
+
40
+	/**
41
+	 * @var SosaModule|null $module
42
+	 */
43
+	private $module;
44
+
45
+	/**
46
+	 * @var SosaRecordsService $sosa_record_service
47
+	 */
48
+	private $sosa_record_service;
49
+
50
+	/**
51
+	 * Constructor for AncestorsListIndividual Request Handler
52
+	 *
53
+	 * @param ModuleService $module_service
54
+	 * @param SosaRecordsService $sosa_record_service
55
+	 */
56
+	public function __construct(
57
+		ModuleService $module_service,
58
+		SosaRecordsService $sosa_record_service
59
+	) {
60
+		$this->module = $module_service->findByInterface(SosaModule::class)->first();
61
+		$this->sosa_record_service = $sosa_record_service;
62
+	}
63
+
64
+	/**
65
+	 * {@inheritDoc}
66
+	 * @see \Psr\Http\Server\RequestHandlerInterface::handle()
67
+	 */
68
+	public function handle(ServerRequestInterface $request): ResponseInterface
69
+	{
70
+		$this->layout = 'layouts/ajax';
71
+
72
+		if ($this->module === null) {
73
+			throw new HttpNotFoundException(I18N::translate('The attached module could not be found.'));
74
+		}
75
+
76
+		$tree = $request->getAttribute('tree');
77
+		assert($tree instanceof Tree);
78
+
79
+		$user = Auth::check() ? $request->getAttribute('user') : new DefaultUser();
80
+
81
+		$current_gen = (int) ($request->getAttribute('gen') ?? 0);
82
+
83
+		if ($current_gen <= 0) {
84
+			return response('Invalid generation', StatusCodeInterface::STATUS_UNPROCESSABLE_ENTITY);
85
+		}
86
+
87
+		$list_ancestors = $this->sosa_record_service->listAncestorsAtGeneration($tree, $user, $current_gen);
88
+		$nb_ancestors_all = $list_ancestors->count();
89
+
90
+		/** @var \Illuminate\Support\Collection<int, \Fisharebest\Webtrees\Individual> $list_ancestors */
91
+		$list_ancestors = $list_ancestors->mapWithKeys(function (stdClass $value) use ($tree): ?array {
92
+				$indi = Registry::individualFactory()->make($value->majs_i_id, $tree);
93
+				return ($indi !== null && $indi->canShowName()) ? [(int) $value->majs_sosa => $indi] : null;
94
+		})->filter();
95
+
96
+		$nb_ancestors_shown = $list_ancestors->count();
97
+
98
+		return $this->viewResponse($this->module->name() . '::list-ancestors-indi-tab', [
99
+			'module_name'       =>  $this->module->name(),
100
+			'title'             =>  I18N::translate('Sosa Ancestors'),
101
+			'tree'              =>  $tree,
102
+			'list_ancestors'    =>  $list_ancestors,
103
+			'nb_ancestors_all'  =>  $nb_ancestors_all,
104
+			'nb_ancestors_theor' =>  pow(2, $current_gen - 1),
105
+			'nb_ancestors_shown' =>  $nb_ancestors_shown
106
+		]);
107
+	}
108 108
 }
Please login to merge, or discard this patch.
app/Module/Sosa/Http/RequestHandlers/MissingAncestorsList.php 1 patch
Indentation   +84 added lines, -84 removed lines patch added patch discarded remove patch
@@ -36,88 +36,88 @@
 block discarded – undo
36 36
  */
37 37
 class MissingAncestorsList implements RequestHandlerInterface
38 38
 {
39
-    use ViewResponseTrait;
40
-
41
-    /**
42
-     * @var SosaModule|null $module
43
-     */
44
-    private $module;
45
-
46
-    /**
47
-     * @var SosaRecordsService $sosa_record_service
48
-     */
49
-    private $sosa_record_service;
50
-
51
-    /**
52
-     * Constructor for MissingAncestorsList Request Handler
53
-     *
54
-     * @param ModuleService $module_service
55
-     * @param SosaRecordsService $sosa_record_service
56
-     */
57
-    public function __construct(
58
-        ModuleService $module_service,
59
-        SosaRecordsService $sosa_record_service
60
-    ) {
61
-        $this->module = $module_service->findByInterface(SosaModule::class)->first();
62
-        $this->sosa_record_service = $sosa_record_service;
63
-    }
64
-
65
-    /**
66
-     * {@inheritDoc}
67
-     * @see \Psr\Http\Server\RequestHandlerInterface::handle()
68
-     */
69
-    public function handle(ServerRequestInterface $request): ResponseInterface
70
-    {
71
-        if ($this->module === null) {
72
-            throw new HttpNotFoundException(I18N::translate('The attached module could not be found.'));
73
-        }
74
-
75
-        $tree = $request->getAttribute('tree');
76
-        assert($tree instanceof Tree);
77
-
78
-        $user = Auth::check() ? $request->getAttribute('user') : new DefaultUser();
79
-
80
-        /** @var SosaStatisticsService $sosa_stats_service */
81
-        $sosa_stats_service = app()->makeWith(SosaStatisticsService::class, ['tree' => $tree, 'user' => $user]);
82
-
83
-        $current_gen = (int) ($request->getQueryParams()['gen'] ?? $request->getAttribute('gen') ?? 0);
84
-
85
-        $list_missing = $this->sosa_record_service->listMissingAncestorsAtGeneration($tree, $user, $current_gen);
86
-        $nb_missing_diff = $list_missing->sum(function (stdClass $value): int {
87
-            return ($value->majs_fat_id === null ? 1 : 0) + ($value->majs_mot_id === null ? 1 : 0);
88
-        });
89
-
90
-        $list_missing = $list_missing->map(function (stdClass $value) use ($tree): ?MissingAncestor {
91
-            $indi = Registry::individualFactory()->make($value->majs_i_id, $tree);
92
-            if ($indi !== null && $indi->canShowName()) {
93
-                return new MissingAncestor(
94
-                    $indi,
95
-                    (int) $value->majs_sosa,
96
-                    $value->majs_fat_id === null,
97
-                    $value->majs_mot_id === null
98
-                );
99
-            }
100
-            return null;
101
-        })->filter();
102
-
103
-        $nb_missing_shown = $list_missing->sum(function (MissingAncestor $value): int {
104
-            return ($value->isFatherMissing() ? 1 : 0) + ($value->isMotherMissing() ? 1 : 0);
105
-        });
106
-
107
-        return $this->viewResponse($this->module->name() . '::list-missing-page', [
108
-            'module_name'       =>  $this->module->name(),
109
-            'title'             =>  I18N::translate('Missing Ancestors'),
110
-            'tree'              =>  $tree,
111
-            'root_indi'         =>  $sosa_stats_service->rootIndividual(),
112
-            'max_gen'           =>  $sosa_stats_service->maxGeneration(),
113
-            'current_gen'       =>  $current_gen,
114
-            'list_missing'      =>  $list_missing,
115
-            'nb_missing_diff'   =>  $nb_missing_diff,
116
-            'nb_missing_shown'  =>  $nb_missing_shown,
117
-            'gen_completeness'  =>
118
-                $sosa_stats_service->totalAncestorsAtGeneration($current_gen) / pow(2, $current_gen - 1),
119
-            'gen_potential'     =>
120
-                $sosa_stats_service->totalAncestorsAtGeneration($current_gen - 1) / pow(2, $current_gen - 2)
121
-        ]);
122
-    }
39
+	use ViewResponseTrait;
40
+
41
+	/**
42
+	 * @var SosaModule|null $module
43
+	 */
44
+	private $module;
45
+
46
+	/**
47
+	 * @var SosaRecordsService $sosa_record_service
48
+	 */
49
+	private $sosa_record_service;
50
+
51
+	/**
52
+	 * Constructor for MissingAncestorsList Request Handler
53
+	 *
54
+	 * @param ModuleService $module_service
55
+	 * @param SosaRecordsService $sosa_record_service
56
+	 */
57
+	public function __construct(
58
+		ModuleService $module_service,
59
+		SosaRecordsService $sosa_record_service
60
+	) {
61
+		$this->module = $module_service->findByInterface(SosaModule::class)->first();
62
+		$this->sosa_record_service = $sosa_record_service;
63
+	}
64
+
65
+	/**
66
+	 * {@inheritDoc}
67
+	 * @see \Psr\Http\Server\RequestHandlerInterface::handle()
68
+	 */
69
+	public function handle(ServerRequestInterface $request): ResponseInterface
70
+	{
71
+		if ($this->module === null) {
72
+			throw new HttpNotFoundException(I18N::translate('The attached module could not be found.'));
73
+		}
74
+
75
+		$tree = $request->getAttribute('tree');
76
+		assert($tree instanceof Tree);
77
+
78
+		$user = Auth::check() ? $request->getAttribute('user') : new DefaultUser();
79
+
80
+		/** @var SosaStatisticsService $sosa_stats_service */
81
+		$sosa_stats_service = app()->makeWith(SosaStatisticsService::class, ['tree' => $tree, 'user' => $user]);
82
+
83
+		$current_gen = (int) ($request->getQueryParams()['gen'] ?? $request->getAttribute('gen') ?? 0);
84
+
85
+		$list_missing = $this->sosa_record_service->listMissingAncestorsAtGeneration($tree, $user, $current_gen);
86
+		$nb_missing_diff = $list_missing->sum(function (stdClass $value): int {
87
+			return ($value->majs_fat_id === null ? 1 : 0) + ($value->majs_mot_id === null ? 1 : 0);
88
+		});
89
+
90
+		$list_missing = $list_missing->map(function (stdClass $value) use ($tree): ?MissingAncestor {
91
+			$indi = Registry::individualFactory()->make($value->majs_i_id, $tree);
92
+			if ($indi !== null && $indi->canShowName()) {
93
+				return new MissingAncestor(
94
+					$indi,
95
+					(int) $value->majs_sosa,
96
+					$value->majs_fat_id === null,
97
+					$value->majs_mot_id === null
98
+				);
99
+			}
100
+			return null;
101
+		})->filter();
102
+
103
+		$nb_missing_shown = $list_missing->sum(function (MissingAncestor $value): int {
104
+			return ($value->isFatherMissing() ? 1 : 0) + ($value->isMotherMissing() ? 1 : 0);
105
+		});
106
+
107
+		return $this->viewResponse($this->module->name() . '::list-missing-page', [
108
+			'module_name'       =>  $this->module->name(),
109
+			'title'             =>  I18N::translate('Missing Ancestors'),
110
+			'tree'              =>  $tree,
111
+			'root_indi'         =>  $sosa_stats_service->rootIndividual(),
112
+			'max_gen'           =>  $sosa_stats_service->maxGeneration(),
113
+			'current_gen'       =>  $current_gen,
114
+			'list_missing'      =>  $list_missing,
115
+			'nb_missing_diff'   =>  $nb_missing_diff,
116
+			'nb_missing_shown'  =>  $nb_missing_shown,
117
+			'gen_completeness'  =>
118
+				$sosa_stats_service->totalAncestorsAtGeneration($current_gen) / pow(2, $current_gen - 1),
119
+			'gen_potential'     =>
120
+				$sosa_stats_service->totalAncestorsAtGeneration($current_gen - 1) / pow(2, $current_gen - 2)
121
+		]);
122
+	}
123 123
 }
Please login to merge, or discard this patch.
app/Module/Sosa/Http/RequestHandlers/AncestorsListFamily.php 1 patch
Indentation   +69 added lines, -69 removed lines patch added patch discarded remove patch
@@ -35,73 +35,73 @@
 block discarded – undo
35 35
  */
36 36
 class AncestorsListFamily implements RequestHandlerInterface
37 37
 {
38
-    use ViewResponseTrait;
39
-
40
-    /**
41
-     * @var SosaModule|null $module
42
-     */
43
-    private $module;
44
-
45
-    /**
46
-     * @var SosaRecordsService $sosa_record_service
47
-     */
48
-    private $sosa_record_service;
49
-
50
-    /**
51
-     * Constructor for AncestorsListFamily Request Handler
52
-     *
53
-     * @param ModuleService $module_service
54
-     * @param SosaRecordsService $sosa_record_service
55
-     */
56
-    public function __construct(
57
-        ModuleService $module_service,
58
-        SosaRecordsService $sosa_record_service
59
-    ) {
60
-        $this->module = $module_service->findByInterface(SosaModule::class)->first();
61
-        $this->sosa_record_service = $sosa_record_service;
62
-    }
63
-
64
-    /**
65
-     * {@inheritDoc}
66
-     * @see \Psr\Http\Server\RequestHandlerInterface::handle()
67
-     */
68
-    public function handle(ServerRequestInterface $request): ResponseInterface
69
-    {
70
-        $this->layout = 'layouts/ajax';
71
-
72
-        if ($this->module === null) {
73
-            throw new HttpNotFoundException(I18N::translate('The attached module could not be found.'));
74
-        }
75
-
76
-        $tree = $request->getAttribute('tree');
77
-        assert($tree instanceof Tree);
78
-
79
-        $user = Auth::check() ? $request->getAttribute('user') : new DefaultUser();
80
-
81
-        $current_gen = (int) ($request->getAttribute('gen') ?? 0);
82
-
83
-        if ($current_gen <= 0) {
84
-            return response('Invalid generation', StatusCodeInterface::STATUS_UNPROCESSABLE_ENTITY);
85
-        }
86
-
87
-        $list_families = $this->sosa_record_service->listAncestorFamiliesAtGeneration($tree, $user, $current_gen);
88
-        $nb_families_all = $list_families->count();
89
-
90
-        /** @var \Illuminate\Support\Collection<int, \Fisharebest\Webtrees\Family> $list_families */
91
-        $list_families = $list_families->mapWithKeys(function (stdClass $value) use ($tree): ?array {
92
-                $fam = Registry::familyFactory()->make($value->f_id, $tree);
93
-                return ($fam !== null && $fam->canShow()) ? [(int) $value->majs_sosa => $fam] : null;
94
-        })->filter();
95
-
96
-        $nb_families_shown = $list_families->count();
97
-
98
-        return $this->viewResponse($this->module->name() . '::list-ancestors-fam-tab', [
99
-            'module_name'       =>  $this->module->name(),
100
-            'title'             =>  I18N::translate('Sosa Ancestors'),
101
-            'tree'              =>  $tree,
102
-            'list_families'     =>  $list_families,
103
-            'nb_families_all'   =>  $nb_families_all,
104
-            'nb_families_shown' =>  $nb_families_shown
105
-        ]);
106
-    }
38
+	use ViewResponseTrait;
39
+
40
+	/**
41
+	 * @var SosaModule|null $module
42
+	 */
43
+	private $module;
44
+
45
+	/**
46
+	 * @var SosaRecordsService $sosa_record_service
47
+	 */
48
+	private $sosa_record_service;
49
+
50
+	/**
51
+	 * Constructor for AncestorsListFamily Request Handler
52
+	 *
53
+	 * @param ModuleService $module_service
54
+	 * @param SosaRecordsService $sosa_record_service
55
+	 */
56
+	public function __construct(
57
+		ModuleService $module_service,
58
+		SosaRecordsService $sosa_record_service
59
+	) {
60
+		$this->module = $module_service->findByInterface(SosaModule::class)->first();
61
+		$this->sosa_record_service = $sosa_record_service;
62
+	}
63
+
64
+	/**
65
+	 * {@inheritDoc}
66
+	 * @see \Psr\Http\Server\RequestHandlerInterface::handle()
67
+	 */
68
+	public function handle(ServerRequestInterface $request): ResponseInterface
69
+	{
70
+		$this->layout = 'layouts/ajax';
71
+
72
+		if ($this->module === null) {
73
+			throw new HttpNotFoundException(I18N::translate('The attached module could not be found.'));
74
+		}
75
+
76
+		$tree = $request->getAttribute('tree');
77
+		assert($tree instanceof Tree);
78
+
79
+		$user = Auth::check() ? $request->getAttribute('user') : new DefaultUser();
80
+
81
+		$current_gen = (int) ($request->getAttribute('gen') ?? 0);
82
+
83
+		if ($current_gen <= 0) {
84
+			return response('Invalid generation', StatusCodeInterface::STATUS_UNPROCESSABLE_ENTITY);
85
+		}
86
+
87
+		$list_families = $this->sosa_record_service->listAncestorFamiliesAtGeneration($tree, $user, $current_gen);
88
+		$nb_families_all = $list_families->count();
89
+
90
+		/** @var \Illuminate\Support\Collection<int, \Fisharebest\Webtrees\Family> $list_families */
91
+		$list_families = $list_families->mapWithKeys(function (stdClass $value) use ($tree): ?array {
92
+				$fam = Registry::familyFactory()->make($value->f_id, $tree);
93
+				return ($fam !== null && $fam->canShow()) ? [(int) $value->majs_sosa => $fam] : null;
94
+		})->filter();
95
+
96
+		$nb_families_shown = $list_families->count();
97
+
98
+		return $this->viewResponse($this->module->name() . '::list-ancestors-fam-tab', [
99
+			'module_name'       =>  $this->module->name(),
100
+			'title'             =>  I18N::translate('Sosa Ancestors'),
101
+			'tree'              =>  $tree,
102
+			'list_families'     =>  $list_families,
103
+			'nb_families_all'   =>  $nb_families_all,
104
+			'nb_families_shown' =>  $nb_families_shown
105
+		]);
106
+	}
107 107
 }
Please login to merge, or discard this patch.
app/Module/Sosa/Http/RequestHandlers/AncestorsList.php 1 patch
Indentation   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -33,59 +33,59 @@
 block discarded – undo
33 33
  */
34 34
 class AncestorsList implements RequestHandlerInterface
35 35
 {
36
-    use ViewResponseTrait;
36
+	use ViewResponseTrait;
37 37
 
38
-    /**
39
-     * @var SosaModule|null $module
40
-     */
41
-    private $module;
38
+	/**
39
+	 * @var SosaModule|null $module
40
+	 */
41
+	private $module;
42 42
 
43
-    /**
44
-     * @var SosaRecordsService $sosa_record_service
45
-     */
46
-    private $sosa_record_service;
43
+	/**
44
+	 * @var SosaRecordsService $sosa_record_service
45
+	 */
46
+	private $sosa_record_service;
47 47
 
48
-    /**
49
-     * Constructor for AncestorsList Request Handler
50
-     *
51
-     * @param ModuleService $module_service
52
-     * @param SosaRecordsService $sosa_record_service
53
-     */
54
-    public function __construct(
55
-        ModuleService $module_service,
56
-        SosaRecordsService $sosa_record_service
57
-    ) {
58
-        $this->module = $module_service->findByInterface(SosaModule::class)->first();
59
-        $this->sosa_record_service = $sosa_record_service;
60
-    }
48
+	/**
49
+	 * Constructor for AncestorsList Request Handler
50
+	 *
51
+	 * @param ModuleService $module_service
52
+	 * @param SosaRecordsService $sosa_record_service
53
+	 */
54
+	public function __construct(
55
+		ModuleService $module_service,
56
+		SosaRecordsService $sosa_record_service
57
+	) {
58
+		$this->module = $module_service->findByInterface(SosaModule::class)->first();
59
+		$this->sosa_record_service = $sosa_record_service;
60
+	}
61 61
 
62
-    /**
63
-     * {@inheritDoc}
64
-     * @see \Psr\Http\Server\RequestHandlerInterface::handle()
65
-     */
66
-    public function handle(ServerRequestInterface $request): ResponseInterface
67
-    {
68
-        if ($this->module === null) {
69
-            throw new HttpNotFoundException(I18N::translate('The attached module could not be found.'));
70
-        }
62
+	/**
63
+	 * {@inheritDoc}
64
+	 * @see \Psr\Http\Server\RequestHandlerInterface::handle()
65
+	 */
66
+	public function handle(ServerRequestInterface $request): ResponseInterface
67
+	{
68
+		if ($this->module === null) {
69
+			throw new HttpNotFoundException(I18N::translate('The attached module could not be found.'));
70
+		}
71 71
 
72
-        $tree = $request->getAttribute('tree');
73
-        assert($tree instanceof Tree);
72
+		$tree = $request->getAttribute('tree');
73
+		assert($tree instanceof Tree);
74 74
 
75
-        $user = Auth::check() ? $request->getAttribute('user') : new DefaultUser();
75
+		$user = Auth::check() ? $request->getAttribute('user') : new DefaultUser();
76 76
 
77
-        /** @var SosaStatisticsService $sosa_stats_service */
78
-        $sosa_stats_service = app()->makeWith(SosaStatisticsService::class, ['tree' => $tree, 'user' => $user]);
77
+		/** @var SosaStatisticsService $sosa_stats_service */
78
+		$sosa_stats_service = app()->makeWith(SosaStatisticsService::class, ['tree' => $tree, 'user' => $user]);
79 79
 
80
-        $current_gen = (int) ($request->getQueryParams()['gen'] ?? $request->getAttribute('gen') ?? 0);
80
+		$current_gen = (int) ($request->getQueryParams()['gen'] ?? $request->getAttribute('gen') ?? 0);
81 81
 
82
-        return $this->viewResponse($this->module->name() . '::list-ancestors-page', [
83
-            'module_name'       =>  $this->module->name(),
84
-            'title'             =>  I18N::translate('Sosa Ancestors'),
85
-            'tree'              =>  $tree,
86
-            'root_indi'         =>  $sosa_stats_service->rootIndividual(),
87
-            'max_gen'           =>  $sosa_stats_service->maxGeneration(),
88
-            'current_gen'       =>  $current_gen
89
-        ]);
90
-    }
82
+		return $this->viewResponse($this->module->name() . '::list-ancestors-page', [
83
+			'module_name'       =>  $this->module->name(),
84
+			'title'             =>  I18N::translate('Sosa Ancestors'),
85
+			'tree'              =>  $tree,
86
+			'root_indi'         =>  $sosa_stats_service->rootIndividual(),
87
+			'max_gen'           =>  $sosa_stats_service->maxGeneration(),
88
+			'current_gen'       =>  $current_gen
89
+		]);
90
+	}
91 91
 }
Please login to merge, or discard this patch.