Passed
Push — feature/code-analysis ( a2ce2d...28b704 )
by Jonathan
04:31
created
app/Module/Certificates/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   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -35,56 +35,56 @@
 block discarded – undo
35 35
  */
36 36
 class AdminConfigPage implements RequestHandlerInterface
37 37
 {
38
-    use ViewResponseTrait;
38
+	use ViewResponseTrait;
39 39
 
40
-    private ?CertificatesModule $module;
41
-    private TreeService $tree_service;
40
+	private ?CertificatesModule $module;
41
+	private TreeService $tree_service;
42 42
 
43
-    /**
44
-     * Constructor for Admin Config page request handler
45
-     *
46
-     * @param ModuleService $module_service
47
-     */
48
-    public function __construct(ModuleService $module_service, TreeService $tree_service)
49
-    {
50
-        $this->module = $module_service->findByInterface(CertificatesModule::class)->first();
51
-        $this->tree_service = $tree_service;
52
-    }
43
+	/**
44
+	 * Constructor for Admin Config page request handler
45
+	 *
46
+	 * @param ModuleService $module_service
47
+	 */
48
+	public function __construct(ModuleService $module_service, TreeService $tree_service)
49
+	{
50
+		$this->module = $module_service->findByInterface(CertificatesModule::class)->first();
51
+		$this->tree_service = $tree_service;
52
+	}
53 53
 
54
-    /**
55
-     * {@inheritDoc}
56
-     * @see \Psr\Http\Server\RequestHandlerInterface::handle()
57
-     */
58
-    public function handle(ServerRequestInterface $request): ResponseInterface
59
-    {
60
-        $this->layout = 'layouts/administration';
54
+	/**
55
+	 * {@inheritDoc}
56
+	 * @see \Psr\Http\Server\RequestHandlerInterface::handle()
57
+	 */
58
+	public function handle(ServerRequestInterface $request): ResponseInterface
59
+	{
60
+		$this->layout = 'layouts/administration';
61 61
 
62
-        if ($this->module === null) {
63
-            throw new HttpNotFoundException(I18N::translate('The attached module could not be found.'));
64
-        }
62
+		if ($this->module === null) {
63
+			throw new HttpNotFoundException(I18N::translate('The attached module could not be found.'));
64
+		}
65 65
 
66
-        $user = Validator::attributes($request)->user();
66
+		$user = Validator::attributes($request)->user();
67 67
 
68
-        $all_trees = $this->tree_service->all()->filter(fn(Tree $tree) => Auth::isManager($tree, $user));
69
-        if ($all_trees->count() === 0) {
70
-            throw new HttpAccessDeniedException();
71
-        }
68
+		$all_trees = $this->tree_service->all()->filter(fn(Tree $tree) => Auth::isManager($tree, $user));
69
+		if ($all_trees->count() === 0) {
70
+			throw new HttpAccessDeniedException();
71
+		}
72 72
 
73
-        $tree = Validator::attributes($request)->treeOptional('tree') ?? $all_trees->first();
73
+		$tree = Validator::attributes($request)->treeOptional('tree') ?? $all_trees->first();
74 74
 
75
-        $data_folder = Registry::filesystem()->dataName();
75
+		$data_folder = Registry::filesystem()->dataName();
76 76
 
77
-        $same_tree = fn(Tree $tree_collection): bool => $tree->id() === $tree_collection->id();
78
-        if (!$all_trees->contains($same_tree)) {
79
-            throw new HttpAccessDeniedException();
80
-        }
77
+		$same_tree = fn(Tree $tree_collection): bool => $tree->id() === $tree_collection->id();
78
+		if (!$all_trees->contains($same_tree)) {
79
+			throw new HttpAccessDeniedException();
80
+		}
81 81
 
82
-        return $this->viewResponse($this->module->name() . '::admin/config', [
83
-            'module_name'       =>  $this->module->name(),
84
-            'title'             =>  $this->module->title(),
85
-            'tree'              =>  $tree,
86
-            'other_trees'       =>  $all_trees->reject($same_tree),
87
-            'data_folder'       =>  $data_folder
88
-        ]);
89
-    }
82
+		return $this->viewResponse($this->module->name() . '::admin/config', [
83
+			'module_name'       =>  $this->module->name(),
84
+			'title'             =>  $this->module->title(),
85
+			'tree'              =>  $tree,
86
+			'other_trees'       =>  $all_trees->reject($same_tree),
87
+			'data_folder'       =>  $data_folder
88
+		]);
89
+	}
90 90
 }
Please login to merge, or discard this patch.
app/Module/Certificates/Http/RequestHandlers/CertificatePage.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -100,7 +100,7 @@
 block discarded – undo
100 100
             return redirect(route(TreePage::class, ['tree' => $tree->name()]));
101 101
         }
102 102
 
103
-        return $this->viewResponse($this->module->name() . '::certificate-page', [
103
+        return $this->viewResponse($this->module->name().'::certificate-page', [
104 104
             'title'                     =>  I18N::translate('Certificate - %s', $certificate->name()),
105 105
             'tree'                      =>  $tree,
106 106
             'module_name'               =>  $this->module->name(),
Please login to merge, or discard this patch.
Indentation   +75 added lines, -75 removed lines patch added patch discarded remove patch
@@ -35,79 +35,79 @@
 block discarded – undo
35 35
  */
36 36
 class CertificatePage implements RequestHandlerInterface
37 37
 {
38
-    use ViewResponseTrait;
39
-
40
-    /**
41
-     * @var CertificatesModule|null $module
42
-     */
43
-    private $module;
44
-
45
-    /**
46
-     * @var CertificateFilesystemService $certif_filesystem
47
-     */
48
-    private $certif_filesystem;
49
-
50
-    /**
51
-     * @var CertificateDataService $certif_data_service
52
-     */
53
-    private $certif_data_service;
54
-
55
-    /**
56
-     * @var UrlObfuscatorService $url_obfuscator_service
57
-     */
58
-    private $url_obfuscator_service;
59
-
60
-
61
-    /**
62
-     * Constructor for CertificatePage Request Handler
63
-     *
64
-     * @param ModuleService $module_service
65
-     * @param CertificateFilesystemService $certif_filesystem
66
-     * @param CertificateDataService $certif_data_service
67
-     * @param UrlObfuscatorService $url_obfuscator_service
68
-     */
69
-    public function __construct(
70
-        ModuleService $module_service,
71
-        CertificateFilesystemService $certif_filesystem,
72
-        CertificateDataService $certif_data_service,
73
-        UrlObfuscatorService $url_obfuscator_service
74
-    ) {
75
-        $this->module = $module_service->findByInterface(CertificatesModule::class)->first();
76
-        $this->certif_filesystem = $certif_filesystem;
77
-        $this->certif_data_service = $certif_data_service;
78
-        $this->url_obfuscator_service = $url_obfuscator_service;
79
-    }
80
-
81
-    /**
82
-     * {@inheritDoc}
83
-     * @see \Psr\Http\Server\RequestHandlerInterface::handle()
84
-     */
85
-    public function handle(ServerRequestInterface $request): ResponseInterface
86
-    {
87
-        if ($this->module === null) {
88
-            throw new HttpNotFoundException(I18N::translate('The attached module could not be found.'));
89
-        }
90
-
91
-        $tree = Validator::attributes($request)->tree();
92
-
93
-        $certif_path = Validator::attributes($request)->string('cid', '');
94
-        if ($certif_path !== '' && $this->url_obfuscator_service->tryDeobfuscate($certif_path)) {
95
-            $certificate = $this->certif_filesystem->certificate($tree, $certif_path);
96
-        }
97
-
98
-        if (!isset($certificate)) {
99
-            FlashMessages::addMessage('The requested certificate is not valid.');
100
-            return redirect(route(TreePage::class, ['tree' => $tree->name()]));
101
-        }
102
-
103
-        return $this->viewResponse($this->module->name() . '::certificate-page', [
104
-            'title'                     =>  I18N::translate('Certificate - %s', $certificate->name()),
105
-            'tree'                      =>  $tree,
106
-            'module_name'               =>  $this->module->name(),
107
-            'certificate'               =>  $certificate,
108
-            'url_obfuscator_service'    =>  $this->url_obfuscator_service,
109
-            'linked_individuals'        =>  $this->certif_data_service->linkedIndividuals($certificate),
110
-            'linked_families'           =>  $this->certif_data_service->linkedFamilies($certificate)
111
-        ]);
112
-    }
38
+	use ViewResponseTrait;
39
+
40
+	/**
41
+	 * @var CertificatesModule|null $module
42
+	 */
43
+	private $module;
44
+
45
+	/**
46
+	 * @var CertificateFilesystemService $certif_filesystem
47
+	 */
48
+	private $certif_filesystem;
49
+
50
+	/**
51
+	 * @var CertificateDataService $certif_data_service
52
+	 */
53
+	private $certif_data_service;
54
+
55
+	/**
56
+	 * @var UrlObfuscatorService $url_obfuscator_service
57
+	 */
58
+	private $url_obfuscator_service;
59
+
60
+
61
+	/**
62
+	 * Constructor for CertificatePage Request Handler
63
+	 *
64
+	 * @param ModuleService $module_service
65
+	 * @param CertificateFilesystemService $certif_filesystem
66
+	 * @param CertificateDataService $certif_data_service
67
+	 * @param UrlObfuscatorService $url_obfuscator_service
68
+	 */
69
+	public function __construct(
70
+		ModuleService $module_service,
71
+		CertificateFilesystemService $certif_filesystem,
72
+		CertificateDataService $certif_data_service,
73
+		UrlObfuscatorService $url_obfuscator_service
74
+	) {
75
+		$this->module = $module_service->findByInterface(CertificatesModule::class)->first();
76
+		$this->certif_filesystem = $certif_filesystem;
77
+		$this->certif_data_service = $certif_data_service;
78
+		$this->url_obfuscator_service = $url_obfuscator_service;
79
+	}
80
+
81
+	/**
82
+	 * {@inheritDoc}
83
+	 * @see \Psr\Http\Server\RequestHandlerInterface::handle()
84
+	 */
85
+	public function handle(ServerRequestInterface $request): ResponseInterface
86
+	{
87
+		if ($this->module === null) {
88
+			throw new HttpNotFoundException(I18N::translate('The attached module could not be found.'));
89
+		}
90
+
91
+		$tree = Validator::attributes($request)->tree();
92
+
93
+		$certif_path = Validator::attributes($request)->string('cid', '');
94
+		if ($certif_path !== '' && $this->url_obfuscator_service->tryDeobfuscate($certif_path)) {
95
+			$certificate = $this->certif_filesystem->certificate($tree, $certif_path);
96
+		}
97
+
98
+		if (!isset($certificate)) {
99
+			FlashMessages::addMessage('The requested certificate is not valid.');
100
+			return redirect(route(TreePage::class, ['tree' => $tree->name()]));
101
+		}
102
+
103
+		return $this->viewResponse($this->module->name() . '::certificate-page', [
104
+			'title'                     =>  I18N::translate('Certificate - %s', $certificate->name()),
105
+			'tree'                      =>  $tree,
106
+			'module_name'               =>  $this->module->name(),
107
+			'certificate'               =>  $certificate,
108
+			'url_obfuscator_service'    =>  $this->url_obfuscator_service,
109
+			'linked_individuals'        =>  $this->certif_data_service->linkedIndividuals($certificate),
110
+			'linked_families'           =>  $this->certif_data_service->linkedFamilies($certificate)
111
+		]);
112
+	}
113 113
 }
Please login to merge, or discard this patch.
app/Module/Certificates/Services/CertificateDataService.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
         $tree = $certificate->tree();
44 44
         return DB::table('individuals')
45 45
             ->where('i_file', '=', $tree->id())
46
-            ->where('i_gedcom', 'like', '% _ACT ' . $this->escapedSqlPath($certificate) . '%')
46
+            ->where('i_gedcom', 'like', '% _ACT '.$this->escapedSqlPath($certificate).'%')
47 47
             ->select(['individuals.*'])
48 48
             ->get()
49 49
             ->map(Registry::individualFactory()->mapper($tree))
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
         $tree = $certificate->tree();
65 65
         return DB::table('families')
66 66
             ->where('f_file', '=', $tree->id())
67
-            ->where('f_gedcom', 'like', '% _ACT ' . $this->escapedSqlPath($certificate) . '%')
67
+            ->where('f_gedcom', 'like', '% _ACT '.$this->escapedSqlPath($certificate).'%')
68 68
             ->select(['families.*'])
69 69
             ->get()
70 70
             ->map(Registry::familyFactory()->mapper($tree))
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
         $tree = $certificate->tree();
86 86
         return DB::table('media')
87 87
             ->where('m_file', '=', $tree->id())
88
-            ->where('m_gedcom', 'like', '% _ACT ' . $this->escapedSqlPath($certificate) . '%')
88
+            ->where('m_gedcom', 'like', '% _ACT '.$this->escapedSqlPath($certificate).'%')
89 89
             ->select(['media.*'])
90 90
             ->get()
91 91
             ->map(Registry::mediaFactory()->mapper($tree))
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
         return DB::table('other')
108 108
             ->where('o_file', '=', $tree->id())
109 109
             ->where('o_type', '=', 'NOTE')
110
-            ->where('o_gedcom', 'like', '% _ACT ' . $this->escapedSqlPath($certificate) . '%')
110
+            ->where('o_gedcom', 'like', '% _ACT '.$this->escapedSqlPath($certificate).'%')
111 111
             ->select(['other.*'])
112 112
             ->get()
113 113
             ->map(Registry::noteFactory()->mapper($tree))
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
     public function oneLinkedSource(Certificate $certificate): ?Source
136 136
     {
137 137
         $regex_query = preg_quote($certificate->gedcomPath(), '/');
138
-        $regex_pattern = '/[1-9] SOUR @(' . Gedcom::REGEX_XREF . ')@(?:\n[2-9]\s(?:(?!SOUR)\w+)\s.*)*\n[2-9] _ACT ' . $regex_query . '/i'; //phpcs:ignore Generic.Files.LineLength.TooLong
138
+        $regex_pattern = '/[1-9] SOUR @('.Gedcom::REGEX_XREF.')@(?:\n[2-9]\s(?:(?!SOUR)\w+)\s.*)*\n[2-9] _ACT '.$regex_query.'/i'; //phpcs:ignore Generic.Files.LineLength.TooLong
139 139
 
140 140
         foreach ($this->linkedRecordsLists($certificate) as $linked_records) {
141 141
             foreach ($linked_records as $gedcom_record) {
Please login to merge, or discard this patch.
Indentation   +132 added lines, -132 removed lines patch added patch discarded remove patch
@@ -28,144 +28,144 @@
 block discarded – undo
28 28
  */
29 29
 class CertificateDataService
30 30
 {
31
-    /**
32
-     * Find individuals linked to a certificate.
33
-     *
34
-     * {@internal Ideally, the underscore should be escaped in the WHERE clause,
35
-     * but does not work with Sqlite if no default escape has been defined}
36
-     *
37
-     * @param Certificate $certificate
38
-     * @return Collection<\Fisharebest\Webtrees\Individual>
39
-     */
40
-    public function linkedIndividuals(Certificate $certificate): Collection
41
-    {
42
-        $tree = $certificate->tree();
43
-        return DB::table('individuals')
44
-            ->where('i_file', '=', $tree->id())
45
-            ->where('i_gedcom', 'like', '% _ACT ' . $this->escapedSqlPath($certificate) . '%')
46
-            ->select(['individuals.*'])
47
-            ->get()
48
-            ->map(Registry::individualFactory()->mapper($tree))
49
-            ->filter(GedcomRecord::accessFilter());
50
-    }
31
+	/**
32
+	 * Find individuals linked to a certificate.
33
+	 *
34
+	 * {@internal Ideally, the underscore should be escaped in the WHERE clause,
35
+	 * but does not work with Sqlite if no default escape has been defined}
36
+	 *
37
+	 * @param Certificate $certificate
38
+	 * @return Collection<\Fisharebest\Webtrees\Individual>
39
+	 */
40
+	public function linkedIndividuals(Certificate $certificate): Collection
41
+	{
42
+		$tree = $certificate->tree();
43
+		return DB::table('individuals')
44
+			->where('i_file', '=', $tree->id())
45
+			->where('i_gedcom', 'like', '% _ACT ' . $this->escapedSqlPath($certificate) . '%')
46
+			->select(['individuals.*'])
47
+			->get()
48
+			->map(Registry::individualFactory()->mapper($tree))
49
+			->filter(GedcomRecord::accessFilter());
50
+	}
51 51
 
52
-    /**
53
-     * Find families linked to a certificate.
54
-     *
55
-     * {@internal Ideally, the underscore should be escaped in the WHERE clause,
56
-     * but does not work with Sqlite if no default escape has been defined}
57
-     *
58
-     * @param Certificate $certificate
59
-     * @return Collection<\Fisharebest\Webtrees\Family>
60
-     */
61
-    public function linkedFamilies(Certificate $certificate): Collection
62
-    {
63
-        $tree = $certificate->tree();
64
-        return DB::table('families')
65
-            ->where('f_file', '=', $tree->id())
66
-            ->where('f_gedcom', 'like', '% _ACT ' . $this->escapedSqlPath($certificate) . '%')
67
-            ->select(['families.*'])
68
-            ->get()
69
-            ->map(Registry::familyFactory()->mapper($tree))
70
-            ->filter(GedcomRecord::accessFilter());
71
-    }
52
+	/**
53
+	 * Find families linked to a certificate.
54
+	 *
55
+	 * {@internal Ideally, the underscore should be escaped in the WHERE clause,
56
+	 * but does not work with Sqlite if no default escape has been defined}
57
+	 *
58
+	 * @param Certificate $certificate
59
+	 * @return Collection<\Fisharebest\Webtrees\Family>
60
+	 */
61
+	public function linkedFamilies(Certificate $certificate): Collection
62
+	{
63
+		$tree = $certificate->tree();
64
+		return DB::table('families')
65
+			->where('f_file', '=', $tree->id())
66
+			->where('f_gedcom', 'like', '% _ACT ' . $this->escapedSqlPath($certificate) . '%')
67
+			->select(['families.*'])
68
+			->get()
69
+			->map(Registry::familyFactory()->mapper($tree))
70
+			->filter(GedcomRecord::accessFilter());
71
+	}
72 72
 
73
-    /**
74
-     * Find media objects linked to a certificate.
75
-     *
76
-     * {@internal Ideally, the underscore should be escaped in the WHERE clause,
77
-     * but does not work with Sqlite if no default escape has been defined}
78
-     *
79
-     * @param Certificate $certificate
80
-     * @return Collection<\Fisharebest\Webtrees\Media>
81
-     */
82
-    public function linkedMedias(Certificate $certificate): Collection
83
-    {
84
-        $tree = $certificate->tree();
85
-        return DB::table('media')
86
-            ->where('m_file', '=', $tree->id())
87
-            ->where('m_gedcom', 'like', '% _ACT ' . $this->escapedSqlPath($certificate) . '%')
88
-            ->select(['media.*'])
89
-            ->get()
90
-            ->map(Registry::mediaFactory()->mapper($tree))
91
-            ->filter(GedcomRecord::accessFilter());
92
-    }
73
+	/**
74
+	 * Find media objects linked to a certificate.
75
+	 *
76
+	 * {@internal Ideally, the underscore should be escaped in the WHERE clause,
77
+	 * but does not work with Sqlite if no default escape has been defined}
78
+	 *
79
+	 * @param Certificate $certificate
80
+	 * @return Collection<\Fisharebest\Webtrees\Media>
81
+	 */
82
+	public function linkedMedias(Certificate $certificate): Collection
83
+	{
84
+		$tree = $certificate->tree();
85
+		return DB::table('media')
86
+			->where('m_file', '=', $tree->id())
87
+			->where('m_gedcom', 'like', '% _ACT ' . $this->escapedSqlPath($certificate) . '%')
88
+			->select(['media.*'])
89
+			->get()
90
+			->map(Registry::mediaFactory()->mapper($tree))
91
+			->filter(GedcomRecord::accessFilter());
92
+	}
93 93
 
94
-    /**
95
-     * Find notes linked to a certificate.
96
-     *
97
-     * {@internal Ideally, the underscore should be escaped in the WHERE clause,
98
-     * but does not work with Sqlite if no default escape has been defined}
99
-     *
100
-     * @param Certificate $certificate
101
-     * @return Collection<\Fisharebest\Webtrees\Note>
102
-     */
103
-    public function linkedNotes(Certificate $certificate): Collection
104
-    {
105
-        $tree = $certificate->tree();
106
-        return DB::table('other')
107
-            ->where('o_file', '=', $tree->id())
108
-            ->where('o_type', '=', 'NOTE')
109
-            ->where('o_gedcom', 'like', '% _ACT ' . $this->escapedSqlPath($certificate) . '%')
110
-            ->select(['other.*'])
111
-            ->get()
112
-            ->map(Registry::noteFactory()->mapper($tree))
113
-            ->filter(GedcomRecord::accessFilter());
114
-    }
94
+	/**
95
+	 * Find notes linked to a certificate.
96
+	 *
97
+	 * {@internal Ideally, the underscore should be escaped in the WHERE clause,
98
+	 * but does not work with Sqlite if no default escape has been defined}
99
+	 *
100
+	 * @param Certificate $certificate
101
+	 * @return Collection<\Fisharebest\Webtrees\Note>
102
+	 */
103
+	public function linkedNotes(Certificate $certificate): Collection
104
+	{
105
+		$tree = $certificate->tree();
106
+		return DB::table('other')
107
+			->where('o_file', '=', $tree->id())
108
+			->where('o_type', '=', 'NOTE')
109
+			->where('o_gedcom', 'like', '% _ACT ' . $this->escapedSqlPath($certificate) . '%')
110
+			->select(['other.*'])
111
+			->get()
112
+			->map(Registry::noteFactory()->mapper($tree))
113
+			->filter(GedcomRecord::accessFilter());
114
+	}
115 115
 
116
-    /**
117
-     * Return an escaped string to be used in SQL LIKE comparisons.
118
-     * This would not work well for Sqlite, if the escape character is not defined.
119
-     *
120
-     * @param Certificate $certificate
121
-     * @return string
122
-     */
123
-    protected function escapedSqlPath(Certificate $certificate): string
124
-    {
125
-        return str_replace(array('\\', '%', '_'), array('\\\\', '\\%', '\\_'), $certificate->gedcomPath());
126
-    }
116
+	/**
117
+	 * Return an escaped string to be used in SQL LIKE comparisons.
118
+	 * This would not work well for Sqlite, if the escape character is not defined.
119
+	 *
120
+	 * @param Certificate $certificate
121
+	 * @return string
122
+	 */
123
+	protected function escapedSqlPath(Certificate $certificate): string
124
+	{
125
+		return str_replace(array('\\', '%', '_'), array('\\\\', '\\%', '\\_'), $certificate->gedcomPath());
126
+	}
127 127
 
128
-    /**
129
-     * Find a source linked to a citation where a certificate file is referenced.
130
-     *
131
-     * @param Certificate $certificate
132
-     * @return Source|NULL
133
-     */
134
-    public function oneLinkedSource(Certificate $certificate): ?Source
135
-    {
136
-        $regex_query = preg_quote($certificate->gedcomPath(), '/');
137
-        $regex_pattern = '/[1-9] SOUR @(' . Gedcom::REGEX_XREF . ')@(?:\n[2-9]\s(?:(?!SOUR)\w+)\s.*)*\n[2-9] _ACT ' . $regex_query . '/i'; //phpcs:ignore Generic.Files.LineLength.TooLong
128
+	/**
129
+	 * Find a source linked to a citation where a certificate file is referenced.
130
+	 *
131
+	 * @param Certificate $certificate
132
+	 * @return Source|NULL
133
+	 */
134
+	public function oneLinkedSource(Certificate $certificate): ?Source
135
+	{
136
+		$regex_query = preg_quote($certificate->gedcomPath(), '/');
137
+		$regex_pattern = '/[1-9] SOUR @(' . Gedcom::REGEX_XREF . ')@(?:\n[2-9]\s(?:(?!SOUR)\w+)\s.*)*\n[2-9] _ACT ' . $regex_query . '/i'; //phpcs:ignore Generic.Files.LineLength.TooLong
138 138
 
139
-        foreach ($this->linkedRecordsLists($certificate) as $linked_records) {
140
-            foreach ($linked_records as $gedcom_record) {
141
-                foreach ($gedcom_record->facts() as $fact) {
142
-                    if (preg_match_all($regex_pattern, $fact->gedcom(), $matches, PREG_SET_ORDER) >= 1) {
143
-                        foreach ($matches as $match) {
144
-                            $source = Registry::sourceFactory()->make($match[1], $certificate->tree());
145
-                            if ($source !== null && $source->canShowName()) {
146
-                                return $source;
147
-                            }
148
-                        }
149
-                    }
150
-                }
151
-            }
152
-        }
139
+		foreach ($this->linkedRecordsLists($certificate) as $linked_records) {
140
+			foreach ($linked_records as $gedcom_record) {
141
+				foreach ($gedcom_record->facts() as $fact) {
142
+					if (preg_match_all($regex_pattern, $fact->gedcom(), $matches, PREG_SET_ORDER) >= 1) {
143
+						foreach ($matches as $match) {
144
+							$source = Registry::sourceFactory()->make($match[1], $certificate->tree());
145
+							if ($source !== null && $source->canShowName()) {
146
+								return $source;
147
+							}
148
+						}
149
+					}
150
+				}
151
+			}
152
+		}
153 153
 
154
-        return null;
155
-    }
154
+		return null;
155
+	}
156 156
 
157
-    /**
158
-     * Yield lists of gedcom records linked to a certificate.
159
-     *
160
-     * @param Certificate $certificate
161
-     * @return Generator<int, Collection<GedcomRecord>, mixed, void>
162
-     * @psalm-suppress InvalidReturnType
163
-     */
164
-    protected function linkedRecordsLists(Certificate $certificate): Generator
165
-    {
166
-        yield $this->linkedIndividuals($certificate);
167
-        yield $this->linkedFamilies($certificate);
168
-        yield $this->linkedMedias($certificate);
169
-        yield $this->linkedNotes($certificate);
170
-    }
157
+	/**
158
+	 * Yield lists of gedcom records linked to a certificate.
159
+	 *
160
+	 * @param Certificate $certificate
161
+	 * @return Generator<int, Collection<GedcomRecord>, mixed, void>
162
+	 * @psalm-suppress InvalidReturnType
163
+	 */
164
+	protected function linkedRecordsLists(Certificate $certificate): Generator
165
+	{
166
+		yield $this->linkedIndividuals($certificate);
167
+		yield $this->linkedFamilies($certificate);
168
+		yield $this->linkedMedias($certificate);
169
+		yield $this->linkedNotes($certificate);
170
+	}
171 171
 }
Please login to merge, or discard this patch.
app/Module/Certificates/Model/Watermark.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -125,6 +125,6 @@
 block discarded – undo
125 125
      */
126 126
     private function stringLengthEstimate(int $text_length, int $font_size): int
127 127
     {
128
-        return $text_length * (int) ceil(($font_size + 2) * 0.5);
128
+        return $text_length * (int)ceil(($font_size + 2) * 0.5);
129 129
     }
130 130
 }
Please login to merge, or discard this patch.
Indentation   +108 added lines, -108 removed lines patch added patch discarded remove patch
@@ -19,112 +19,112 @@
 block discarded – undo
19 19
  */
20 20
 class Watermark
21 21
 {
22
-    /**
23
-     * Default font color for watermarks
24
-     * @var string DEFAULT_COLOR
25
-     * */
26
-    public const DEFAULT_COLOR = '#4D6DF3';
27
-
28
-    /**
29
-     * Default maximum font size for watermarks
30
-     * @var int DEFAULT_SIZE
31
-     * */
32
-    public const DEFAULT_SIZE = 18;
33
-
34
-    /**
35
-     * @var string $text
36
-     */
37
-    private $text;
38
-
39
-    /**
40
-     * @var string $color;
41
-     */
42
-    private $color;
43
-
44
-
45
-    /**
46
-     * @var int $size
47
-     */
48
-    private $size;
49
-
50
-    /**
51
-     * Constructor for Watermark data class
52
-     *
53
-     * @param string $text
54
-     * @param string $color
55
-     * @param int $size
56
-     */
57
-    public function __construct(string $text, string $color, int $size)
58
-    {
59
-        $this->text = $text;
60
-        $this->color = $color;
61
-        $this->size = $size;
62
-    }
63
-
64
-    /**
65
-     * Get the watermark text.
66
-     *
67
-     * @return string
68
-     */
69
-    public function text(): string
70
-    {
71
-        return $this->text;
72
-    }
73
-
74
-    /**
75
-     * Get the watermark font color.
76
-     *
77
-     * @return string
78
-     */
79
-    public function color(): string
80
-    {
81
-        return $this->color;
82
-    }
83
-
84
-    /**
85
-     * Get the watermark maximum font size.
86
-     * @return int
87
-     */
88
-    public function size(): int
89
-    {
90
-        return $this->size;
91
-    }
92
-
93
-    /**
94
-     * Return an estimate of the size in pixels of the watermark text length.
95
-     *
96
-     * @return int
97
-     */
98
-    public function textLengthEstimate(): int
99
-    {
100
-        return $this->stringLengthEstimate(mb_strlen($this->text), $this->size);
101
-    }
102
-
103
-    /**
104
-     * Decrease the font size if necessary, based on the image width.
105
-     *
106
-     * @param int $width
107
-     */
108
-    public function adjustSize(int $width): void
109
-    {
110
-        $len = mb_strlen($this->text);
111
-        while ($this->stringLengthEstimate($len, $this->size) > 0.9 * $width) {
112
-            $this->size--;
113
-            if ($this->size == 2) {
114
-                return;
115
-            }
116
-        }
117
-    }
118
-
119
-    /**
120
-     * Return an estimate of the size in pixels of a text in a specified font size.
121
-     *
122
-     * @param int $text_length
123
-     * @param int $font_size
124
-     * @return int
125
-     */
126
-    private function stringLengthEstimate(int $text_length, int $font_size): int
127
-    {
128
-        return $text_length * (int) ceil(($font_size + 2) * 0.5);
129
-    }
22
+	/**
23
+	 * Default font color for watermarks
24
+	 * @var string DEFAULT_COLOR
25
+	 * */
26
+	public const DEFAULT_COLOR = '#4D6DF3';
27
+
28
+	/**
29
+	 * Default maximum font size for watermarks
30
+	 * @var int DEFAULT_SIZE
31
+	 * */
32
+	public const DEFAULT_SIZE = 18;
33
+
34
+	/**
35
+	 * @var string $text
36
+	 */
37
+	private $text;
38
+
39
+	/**
40
+	 * @var string $color;
41
+	 */
42
+	private $color;
43
+
44
+
45
+	/**
46
+	 * @var int $size
47
+	 */
48
+	private $size;
49
+
50
+	/**
51
+	 * Constructor for Watermark data class
52
+	 *
53
+	 * @param string $text
54
+	 * @param string $color
55
+	 * @param int $size
56
+	 */
57
+	public function __construct(string $text, string $color, int $size)
58
+	{
59
+		$this->text = $text;
60
+		$this->color = $color;
61
+		$this->size = $size;
62
+	}
63
+
64
+	/**
65
+	 * Get the watermark text.
66
+	 *
67
+	 * @return string
68
+	 */
69
+	public function text(): string
70
+	{
71
+		return $this->text;
72
+	}
73
+
74
+	/**
75
+	 * Get the watermark font color.
76
+	 *
77
+	 * @return string
78
+	 */
79
+	public function color(): string
80
+	{
81
+		return $this->color;
82
+	}
83
+
84
+	/**
85
+	 * Get the watermark maximum font size.
86
+	 * @return int
87
+	 */
88
+	public function size(): int
89
+	{
90
+		return $this->size;
91
+	}
92
+
93
+	/**
94
+	 * Return an estimate of the size in pixels of the watermark text length.
95
+	 *
96
+	 * @return int
97
+	 */
98
+	public function textLengthEstimate(): int
99
+	{
100
+		return $this->stringLengthEstimate(mb_strlen($this->text), $this->size);
101
+	}
102
+
103
+	/**
104
+	 * Decrease the font size if necessary, based on the image width.
105
+	 *
106
+	 * @param int $width
107
+	 */
108
+	public function adjustSize(int $width): void
109
+	{
110
+		$len = mb_strlen($this->text);
111
+		while ($this->stringLengthEstimate($len, $this->size) > 0.9 * $width) {
112
+			$this->size--;
113
+			if ($this->size == 2) {
114
+				return;
115
+			}
116
+		}
117
+	}
118
+
119
+	/**
120
+	 * Return an estimate of the size in pixels of a text in a specified font size.
121
+	 *
122
+	 * @param int $text_length
123
+	 * @param int $font_size
124
+	 * @return int
125
+	 */
126
+	private function stringLengthEstimate(int $text_length, int $font_size): int
127
+	{
128
+		return $text_length * (int) ceil(($font_size + 2) * 0.5);
129
+	}
130 130
 }
Please login to merge, or discard this patch.
app/Module/Certificates/Model/Certificate.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -202,11 +202,11 @@
 block discarded – undo
202 202
     {
203 203
         $sort_prefix = '';
204 204
         if (preg_match_all('/\b([A-Z]{3,})\b/', $this->description(), $matches, PREG_SET_ORDER) >= 1) {
205
-            $sort_prefix = implode('_', array_map(function ($match) {
205
+            $sort_prefix = implode('_', array_map(function($match) {
206 206
                 return $match[1];
207
-            }, $matches)) . '_';
207
+            }, $matches)).'_';
208 208
         }
209
-        return $sort_prefix . $this->description();
209
+        return $sort_prefix.$this->description();
210 210
     }
211 211
 
212 212
     /**
Please login to merge, or discard this patch.
Indentation   +189 added lines, -189 removed lines patch added patch discarded remove patch
@@ -25,193 +25,193 @@
 block discarded – undo
25 25
  */
26 26
 class Certificate
27 27
 {
28
-    /**
29
-     * Pattern to extract information from a file name.
30
-     * Specific to the author's workflow.
31
-     * @var string
32
-     */
33
-    private const FILENAME_PATTERN = '/^(?<year>\d{1,4})(\.(?<month>\d{1,2}))?(\.(?<day>\d{1,2}))?( (?<type>[A-Z]{1,2}))?\s(?<descr>.*)/'; //phpcs:ignore Generic.Files.LineLength.TooLong
34
-
35
-    private Tree $tree;
36
-    private string $path;
37
-    private ?string $city = null;
38
-    private ?string $basename = null;
39
-    private ?string $filename = null;
40
-    private ?string $extension = null;
41
-    private ?string $type = null;
42
-    private ?string $description = null;
43
-    private ?Date $date = null;
44
-
45
-    /**
46
-     * Contructor for Certificate
47
-     *
48
-     * @param Tree $tree
49
-     * @param string $path
50
-     */
51
-    public function __construct(Tree $tree, string $path)
52
-    {
53
-        $this->tree = $tree;
54
-        $this->path = $path;
55
-        $this->extractDataFromPath($path);
56
-    }
57
-
58
-    /**
59
-     * Populate fields from the filename, based on a predeterminate pattern.
60
-     * Logic specific to the author.
61
-     *
62
-     * @param string $path
63
-     */
64
-    protected function extractDataFromPath(string $path): void
65
-    {
66
-        $path_parts = pathinfo($this->gedcomPath());
67
-        $this->city = $path_parts['dirname'];
68
-        $this->basename = $path_parts['basename'];
69
-        $this->filename = $path_parts['filename'];
70
-        $this->extension = strtoupper($path_parts['extension'] ?? '');
71
-
72
-        if (preg_match(self::FILENAME_PATTERN, $this->filename, $match) === 1) {
73
-            $this->type = $match['type'];
74
-            $this->description = $match['descr'];
75
-
76
-            $day = $match['day'] ?? '';
77
-            $month_date = DateTime::createFromFormat('m', $match['month'] ?? '');
78
-            $month = $month_date !== false ? strtoupper($month_date->format('M')) : '';
79
-            $year = $match['year'] ?? '';
80
-
81
-            $this->date = new Date(sprintf('%s %s %s', $day, $month, $year));
82
-        } else {
83
-            $this->description = $this->filename;
84
-        }
85
-    }
86
-
87
-    /**
88
-     * Get the family tree of the certificate
89
-     *
90
-     * @return Tree
91
-     */
92
-    public function tree(): Tree
93
-    {
94
-        return $this->tree;
95
-    }
96
-
97
-    /**
98
-     * Get the path of the certificate in the file system.
99
-     *
100
-     * @return string
101
-     */
102
-    public function path(): string
103
-    {
104
-        return $this->path;
105
-    }
106
-
107
-    /**
108
-     * The the path of the certificate, in a Gedcom canonical form.
109
-     *
110
-     * @return string
111
-     */
112
-    public function gedcomPath(): string
113
-    {
114
-        return str_replace('\\', '/', $this->path);
115
-    }
116
-
117
-    /**
118
-     * Get the certificate name.
119
-     *
120
-     * @return string
121
-     */
122
-    public function name(): string
123
-    {
124
-        return $this->filename ?? '';
125
-    }
126
-
127
-    /**
128
-     * Get the certificate file name.
129
-     *
130
-     * @return string
131
-     */
132
-    public function filename(): string
133
-    {
134
-        return $this->basename ?? '';
135
-    }
136
-
137
-    /**
138
-     * Get the certificate's city (the first level folder).
139
-     *
140
-     * @return string
141
-     */
142
-    public function city(): string
143
-    {
144
-        return $this->city ?? '';
145
-    }
146
-
147
-    /**
148
-     * Get the certificate's date. Extracted from the file name.
149
-     *
150
-     * @return Date
151
-     */
152
-    public function date(): Date
153
-    {
154
-        return $this->date ?? new Date('');
155
-    }
156
-
157
-    /**
158
-     * Get the certificate's type. Extracted from the file name.
159
-     *
160
-     * @return string
161
-     */
162
-    public function type(): string
163
-    {
164
-        return $this->type ?? '';
165
-    }
166
-
167
-    /**
168
-     * Get the certificate's description.  Extracted from the file name.
169
-     * @return string
170
-     */
171
-    public function description(): string
172
-    {
173
-        return $this->description ?? '';
174
-    }
175
-
176
-    /**
177
-     * Get the certificate's description to be used for sorting.
178
-     * This is based on surnames (at least 3 letters) found in the file name.
179
-     *
180
-     * @return string
181
-     */
182
-    public function sortDescription(): string
183
-    {
184
-        $sort_prefix = '';
185
-        if (preg_match_all('/\b([A-Z]{3,})\b/', $this->description(), $matches, PREG_SET_ORDER) >= 1) {
186
-            $sort_prefix = implode('_', array_map(function ($match) {
187
-                return $match[1];
188
-            }, $matches)) . '_';
189
-        }
190
-        return $sort_prefix . $this->description();
191
-    }
192
-
193
-    /**
194
-     * Get the certificate's MIME type.
195
-     *
196
-     * @return string
197
-     */
198
-    public function mimeType(): string
199
-    {
200
-        return Mime::TYPES[$this->extension] ?? Mime::DEFAULT_TYPE;
201
-    }
202
-
203
-    /**
204
-     * Get the base parameters to be used in url referencing the certificate.
205
-     *
206
-     * @param UrlObfuscatorService $url_obfuscator_service
207
-     * @return array{tree: string, cid: mixed}
208
-     */
209
-    public function urlParameters(UrlObfuscatorService $url_obfuscator_service = null): array
210
-    {
211
-        $url_obfuscator_service = $url_obfuscator_service ?? app(UrlObfuscatorService::class);
212
-        return [
213
-            'tree' => $this->tree->name(),
214
-            'cid' => $url_obfuscator_service->obfuscate($this->path)
215
-        ];
216
-    }
28
+	/**
29
+	 * Pattern to extract information from a file name.
30
+	 * Specific to the author's workflow.
31
+	 * @var string
32
+	 */
33
+	private const FILENAME_PATTERN = '/^(?<year>\d{1,4})(\.(?<month>\d{1,2}))?(\.(?<day>\d{1,2}))?( (?<type>[A-Z]{1,2}))?\s(?<descr>.*)/'; //phpcs:ignore Generic.Files.LineLength.TooLong
34
+
35
+	private Tree $tree;
36
+	private string $path;
37
+	private ?string $city = null;
38
+	private ?string $basename = null;
39
+	private ?string $filename = null;
40
+	private ?string $extension = null;
41
+	private ?string $type = null;
42
+	private ?string $description = null;
43
+	private ?Date $date = null;
44
+
45
+	/**
46
+	 * Contructor for Certificate
47
+	 *
48
+	 * @param Tree $tree
49
+	 * @param string $path
50
+	 */
51
+	public function __construct(Tree $tree, string $path)
52
+	{
53
+		$this->tree = $tree;
54
+		$this->path = $path;
55
+		$this->extractDataFromPath($path);
56
+	}
57
+
58
+	/**
59
+	 * Populate fields from the filename, based on a predeterminate pattern.
60
+	 * Logic specific to the author.
61
+	 *
62
+	 * @param string $path
63
+	 */
64
+	protected function extractDataFromPath(string $path): void
65
+	{
66
+		$path_parts = pathinfo($this->gedcomPath());
67
+		$this->city = $path_parts['dirname'];
68
+		$this->basename = $path_parts['basename'];
69
+		$this->filename = $path_parts['filename'];
70
+		$this->extension = strtoupper($path_parts['extension'] ?? '');
71
+
72
+		if (preg_match(self::FILENAME_PATTERN, $this->filename, $match) === 1) {
73
+			$this->type = $match['type'];
74
+			$this->description = $match['descr'];
75
+
76
+			$day = $match['day'] ?? '';
77
+			$month_date = DateTime::createFromFormat('m', $match['month'] ?? '');
78
+			$month = $month_date !== false ? strtoupper($month_date->format('M')) : '';
79
+			$year = $match['year'] ?? '';
80
+
81
+			$this->date = new Date(sprintf('%s %s %s', $day, $month, $year));
82
+		} else {
83
+			$this->description = $this->filename;
84
+		}
85
+	}
86
+
87
+	/**
88
+	 * Get the family tree of the certificate
89
+	 *
90
+	 * @return Tree
91
+	 */
92
+	public function tree(): Tree
93
+	{
94
+		return $this->tree;
95
+	}
96
+
97
+	/**
98
+	 * Get the path of the certificate in the file system.
99
+	 *
100
+	 * @return string
101
+	 */
102
+	public function path(): string
103
+	{
104
+		return $this->path;
105
+	}
106
+
107
+	/**
108
+	 * The the path of the certificate, in a Gedcom canonical form.
109
+	 *
110
+	 * @return string
111
+	 */
112
+	public function gedcomPath(): string
113
+	{
114
+		return str_replace('\\', '/', $this->path);
115
+	}
116
+
117
+	/**
118
+	 * Get the certificate name.
119
+	 *
120
+	 * @return string
121
+	 */
122
+	public function name(): string
123
+	{
124
+		return $this->filename ?? '';
125
+	}
126
+
127
+	/**
128
+	 * Get the certificate file name.
129
+	 *
130
+	 * @return string
131
+	 */
132
+	public function filename(): string
133
+	{
134
+		return $this->basename ?? '';
135
+	}
136
+
137
+	/**
138
+	 * Get the certificate's city (the first level folder).
139
+	 *
140
+	 * @return string
141
+	 */
142
+	public function city(): string
143
+	{
144
+		return $this->city ?? '';
145
+	}
146
+
147
+	/**
148
+	 * Get the certificate's date. Extracted from the file name.
149
+	 *
150
+	 * @return Date
151
+	 */
152
+	public function date(): Date
153
+	{
154
+		return $this->date ?? new Date('');
155
+	}
156
+
157
+	/**
158
+	 * Get the certificate's type. Extracted from the file name.
159
+	 *
160
+	 * @return string
161
+	 */
162
+	public function type(): string
163
+	{
164
+		return $this->type ?? '';
165
+	}
166
+
167
+	/**
168
+	 * Get the certificate's description.  Extracted from the file name.
169
+	 * @return string
170
+	 */
171
+	public function description(): string
172
+	{
173
+		return $this->description ?? '';
174
+	}
175
+
176
+	/**
177
+	 * Get the certificate's description to be used for sorting.
178
+	 * This is based on surnames (at least 3 letters) found in the file name.
179
+	 *
180
+	 * @return string
181
+	 */
182
+	public function sortDescription(): string
183
+	{
184
+		$sort_prefix = '';
185
+		if (preg_match_all('/\b([A-Z]{3,})\b/', $this->description(), $matches, PREG_SET_ORDER) >= 1) {
186
+			$sort_prefix = implode('_', array_map(function ($match) {
187
+				return $match[1];
188
+			}, $matches)) . '_';
189
+		}
190
+		return $sort_prefix . $this->description();
191
+	}
192
+
193
+	/**
194
+	 * Get the certificate's MIME type.
195
+	 *
196
+	 * @return string
197
+	 */
198
+	public function mimeType(): string
199
+	{
200
+		return Mime::TYPES[$this->extension] ?? Mime::DEFAULT_TYPE;
201
+	}
202
+
203
+	/**
204
+	 * Get the base parameters to be used in url referencing the certificate.
205
+	 *
206
+	 * @param UrlObfuscatorService $url_obfuscator_service
207
+	 * @return array{tree: string, cid: mixed}
208
+	 */
209
+	public function urlParameters(UrlObfuscatorService $url_obfuscator_service = null): array
210
+	{
211
+		$url_obfuscator_service = $url_obfuscator_service ?? app(UrlObfuscatorService::class);
212
+		return [
213
+			'tree' => $this->tree->name(),
214
+			'cid' => $url_obfuscator_service->obfuscate($this->path)
215
+		];
216
+	}
217 217
 }
Please login to merge, or discard this patch.
app/Module/Certificates/Elements/SourceCertificate.php 2 patches
Indentation   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -28,61 +28,61 @@
 block discarded – undo
28 28
  */
29 29
 class SourceCertificate extends AbstractElement
30 30
 {
31
-    protected CertificatesModule $module;
32
-    protected CertificateFilesystemService $certif_filesystem;
33
-    protected UrlObfuscatorService $url_obfuscator_service;
31
+	protected CertificatesModule $module;
32
+	protected CertificateFilesystemService $certif_filesystem;
33
+	protected UrlObfuscatorService $url_obfuscator_service;
34 34
 
35
-    /**
36
-     * Constructor for SourceCertificate element
37
-     *
38
-     * @param string $label
39
-     * @param CertificatesModule $module
40
-     * @param CertificateFilesystemService $certif_filesystem
41
-     * @param UrlObfuscatorService $url_obfuscator_service
42
-     */
43
-    public function __construct(
44
-        string $label,
45
-        CertificatesModule $module,
46
-        CertificateFilesystemService $certif_filesystem = null,
47
-        UrlObfuscatorService $url_obfuscator_service = null
48
-    ) {
49
-        parent::__construct($label, null);
50
-        $this->module = $module;
51
-        $this->certif_filesystem = $certif_filesystem ?? app(CertificateFilesystemService::class);
52
-        $this->url_obfuscator_service = $url_obfuscator_service ?? app(UrlObfuscatorService::class);
53
-    }
35
+	/**
36
+	 * Constructor for SourceCertificate element
37
+	 *
38
+	 * @param string $label
39
+	 * @param CertificatesModule $module
40
+	 * @param CertificateFilesystemService $certif_filesystem
41
+	 * @param UrlObfuscatorService $url_obfuscator_service
42
+	 */
43
+	public function __construct(
44
+		string $label,
45
+		CertificatesModule $module,
46
+		CertificateFilesystemService $certif_filesystem = null,
47
+		UrlObfuscatorService $url_obfuscator_service = null
48
+	) {
49
+		parent::__construct($label, null);
50
+		$this->module = $module;
51
+		$this->certif_filesystem = $certif_filesystem ?? app(CertificateFilesystemService::class);
52
+		$this->url_obfuscator_service = $url_obfuscator_service ?? app(UrlObfuscatorService::class);
53
+	}
54 54
 
55
-    /**
56
-     * {@inheritDoc}
57
-     * @see \Fisharebest\Webtrees\Elements\AbstractElement::canonical()
58
-     */
59
-    public function canonical($value): string
60
-    {
61
-        return strtr($value, '\\', '/');
62
-    }
55
+	/**
56
+	 * {@inheritDoc}
57
+	 * @see \Fisharebest\Webtrees\Elements\AbstractElement::canonical()
58
+	 */
59
+	public function canonical($value): string
60
+	{
61
+		return strtr($value, '\\', '/');
62
+	}
63 63
 
64
-    /**
65
-     * {@inheritDoc}
66
-     * @see \Fisharebest\Webtrees\Elements\AbstractElement::edit()
67
-     */
68
-    public function edit(string $id, string $name, string $value, Tree $tree): string
69
-    {
70
-        list($city, $file) = explode('/', $this->canonical($value), 2) + ['', ''];
64
+	/**
65
+	 * {@inheritDoc}
66
+	 * @see \Fisharebest\Webtrees\Elements\AbstractElement::edit()
67
+	 */
68
+	public function edit(string $id, string $name, string $value, Tree $tree): string
69
+	{
70
+		list($city, $file) = explode('/', $this->canonical($value), 2) + ['', ''];
71 71
 
72
-        $cities = array_map(function (string $item): array {
73
-            return [$this->url_obfuscator_service->obfuscate($item), $item];
74
-        }, $this->certif_filesystem->cities($tree));
72
+		$cities = array_map(function (string $item): array {
73
+			return [$this->url_obfuscator_service->obfuscate($item), $item];
74
+		}, $this->certif_filesystem->cities($tree));
75 75
 
76
-        return view($this->module->name() . '::components/edit-certificate', [
77
-            'module_name'   =>  $this->module->name(),
78
-            'tree'          =>  $tree,
79
-            'id'            =>  $id,
80
-            'name'          =>  $name,
81
-            'cities'        =>  $cities,
82
-            'value'         =>  $this->canonical($value),
83
-            'value_city'    =>  $city,
84
-            'value_file'    =>  $file,
85
-            'js_script_url' =>  $this->module->assetUrl('js/certificates.min.js')
86
-        ]);
87
-    }
76
+		return view($this->module->name() . '::components/edit-certificate', [
77
+			'module_name'   =>  $this->module->name(),
78
+			'tree'          =>  $tree,
79
+			'id'            =>  $id,
80
+			'name'          =>  $name,
81
+			'cities'        =>  $cities,
82
+			'value'         =>  $this->canonical($value),
83
+			'value_city'    =>  $city,
84
+			'value_file'    =>  $file,
85
+			'js_script_url' =>  $this->module->assetUrl('js/certificates.min.js')
86
+		]);
87
+	}
88 88
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -69,11 +69,11 @@
 block discarded – undo
69 69
     {
70 70
         list($city, $file) = explode('/', $this->canonical($value), 2) + ['', ''];
71 71
 
72
-        $cities = array_map(function (string $item): array {
72
+        $cities = array_map(function(string $item): array {
73 73
             return [$this->url_obfuscator_service->obfuscate($item), $item];
74 74
         }, $this->certif_filesystem->cities($tree));
75 75
 
76
-        return view($this->module->name() . '::components/edit-certificate', [
76
+        return view($this->module->name().'::components/edit-certificate', [
77 77
             'module_name'   =>  $this->module->name(),
78 78
             'tree'          =>  $tree,
79 79
             'id'            =>  $id,
Please login to merge, or discard this patch.
app/Module/AdminTasks/Http/RequestHandlers/AdminConfigPage.php 2 patches
Indentation   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -29,47 +29,47 @@
 block discarded – undo
29 29
  */
30 30
 class AdminConfigPage implements RequestHandlerInterface
31 31
 {
32
-    use ViewResponseTrait;
32
+	use ViewResponseTrait;
33 33
 
34
-    private ?AdminTasksModule $module;
35
-    private TokenService $token_service;
34
+	private ?AdminTasksModule $module;
35
+	private TokenService $token_service;
36 36
 
37
-    /**
38
-     * Constructor for Admin Config request handler
39
-     *
40
-     * @param ModuleService $module_service
41
-     */
42
-    public function __construct(ModuleService $module_service, TokenService $token_service)
43
-    {
44
-        $this->module = $module_service->findByInterface(AdminTasksModule::class)->first();
45
-        $this->token_service = $token_service;
46
-    }
37
+	/**
38
+	 * Constructor for Admin Config request handler
39
+	 *
40
+	 * @param ModuleService $module_service
41
+	 */
42
+	public function __construct(ModuleService $module_service, TokenService $token_service)
43
+	{
44
+		$this->module = $module_service->findByInterface(AdminTasksModule::class)->first();
45
+		$this->token_service = $token_service;
46
+	}
47 47
 
48
-    /**
49
-     * {@inheritDoc}
50
-     * @see \Psr\Http\Server\RequestHandlerInterface::handle()
51
-     */
52
-    public function handle(ServerRequestInterface $request): ResponseInterface
53
-    {
54
-        $this->layout = 'layouts/administration';
48
+	/**
49
+	 * {@inheritDoc}
50
+	 * @see \Psr\Http\Server\RequestHandlerInterface::handle()
51
+	 */
52
+	public function handle(ServerRequestInterface $request): ResponseInterface
53
+	{
54
+		$this->layout = 'layouts/administration';
55 55
 
56
-        if ($this->module === null) {
57
-            throw new HttpNotFoundException(I18N::translate('The attached module could not be found.'));
58
-        }
56
+		if ($this->module === null) {
57
+			throw new HttpNotFoundException(I18N::translate('The attached module could not be found.'));
58
+		}
59 59
 
60
-        $token = $this->module->getPreference('MAJ_AT_FORCE_EXEC_TOKEN');
61
-        if ($token === '') {
62
-            $token = $this->token_service->generateRandomToken();
63
-            $this->module->setPreference('PAT_FORCE_EXEC_TOKEN', $token);
64
-        }
60
+		$token = $this->module->getPreference('MAJ_AT_FORCE_EXEC_TOKEN');
61
+		if ($token === '') {
62
+			$token = $this->token_service->generateRandomToken();
63
+			$this->module->setPreference('PAT_FORCE_EXEC_TOKEN', $token);
64
+		}
65 65
 
66
-        return $this->viewResponse($this->module->name() . '::admin/config', [
67
-            'title'             =>  $this->module->title(),
68
-            'trigger_token'     =>  $token,
69
-            'trigger_route'     =>  route(TaskTrigger::class, ['task' => '__TASKNAME__', 'force' => '__TOKEN__']),
70
-            'new_token_route'   =>  route(TokenGenerate::class),
71
-            'tasks_data_route'  =>  route(TasksList::class),
72
-            'js_script_url'     =>  $this->module->assetUrl('js/admintasks.min.js')
73
-        ]);
74
-    }
66
+		return $this->viewResponse($this->module->name() . '::admin/config', [
67
+			'title'             =>  $this->module->title(),
68
+			'trigger_token'     =>  $token,
69
+			'trigger_route'     =>  route(TaskTrigger::class, ['task' => '__TASKNAME__', 'force' => '__TOKEN__']),
70
+			'new_token_route'   =>  route(TokenGenerate::class),
71
+			'tasks_data_route'  =>  route(TasksList::class),
72
+			'js_script_url'     =>  $this->module->assetUrl('js/admintasks.min.js')
73
+		]);
74
+	}
75 75
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -73,7 +73,7 @@
 block discarded – undo
73 73
             $this->module->setPreference('PAT_FORCE_EXEC_TOKEN', $token);
74 74
         }
75 75
         
76
-        return $this->viewResponse($this->module->name() . '::admin/config', [
76
+        return $this->viewResponse($this->module->name().'::admin/config', [
77 77
             'title'             =>  $this->module->title(),
78 78
             'trigger_token'     =>  $token,
79 79
             'trigger_route'     =>  route(TaskTrigger::class, ['task' => '__TASKNAME__', 'force' => '__TOKEN__']),
Please login to merge, or discard this patch.
app/Module/AdminTasks/Http/RequestHandlers/TokenGenerate.php 2 patches
Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -30,34 +30,34 @@
 block discarded – undo
30 30
  */
31 31
 class TokenGenerate implements RequestHandlerInterface
32 32
 {
33
-    private ?AdminTasksModule $module;
34
-    private TokenService $token_service;
35
-
36
-    /**
37
-     * Constructor for TokenGenerate request handler
38
-     *
39
-     * @param ModuleService $module_service
40
-     */
41
-    public function __construct(ModuleService $module_service, TokenService $token_service)
42
-    {
43
-        $this->module = $module_service->findByInterface(AdminTasksModule::class)->first();
44
-        $this->token_service = $token_service;
45
-    }
46
-
47
-    /**
48
-     * {@inheritDoc}
49
-     * @see \Psr\Http\Server\RequestHandlerInterface::handle()
50
-     */
51
-    public function handle(ServerRequestInterface $request): ResponseInterface
52
-    {
53
-        if ($this->module === null) {
54
-            throw new HttpNotFoundException(I18N::translate('The attached module could not be found.'));
55
-        }
56
-
57
-        $token = $this->token_service->generateRandomToken();
58
-        $this->module->setPreference('MAJ_AT_FORCE_EXEC_TOKEN', $token);
59
-        Log::addConfigurationLog($this->module->title() . ' : New token generated.');
60
-
61
-        return response(['token' => $token]);
62
-    }
33
+	private ?AdminTasksModule $module;
34
+	private TokenService $token_service;
35
+
36
+	/**
37
+	 * Constructor for TokenGenerate request handler
38
+	 *
39
+	 * @param ModuleService $module_service
40
+	 */
41
+	public function __construct(ModuleService $module_service, TokenService $token_service)
42
+	{
43
+		$this->module = $module_service->findByInterface(AdminTasksModule::class)->first();
44
+		$this->token_service = $token_service;
45
+	}
46
+
47
+	/**
48
+	 * {@inheritDoc}
49
+	 * @see \Psr\Http\Server\RequestHandlerInterface::handle()
50
+	 */
51
+	public function handle(ServerRequestInterface $request): ResponseInterface
52
+	{
53
+		if ($this->module === null) {
54
+			throw new HttpNotFoundException(I18N::translate('The attached module could not be found.'));
55
+		}
56
+
57
+		$token = $this->token_service->generateRandomToken();
58
+		$this->module->setPreference('MAJ_AT_FORCE_EXEC_TOKEN', $token);
59
+		Log::addConfigurationLog($this->module->title() . ' : New token generated.');
60
+
61
+		return response(['token' => $token]);
62
+	}
63 63
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@
 block discarded – undo
56 56
 
57 57
         $token = $this->token_service->generateRandomToken();
58 58
         $this->module->setPreference('MAJ_AT_FORCE_EXEC_TOKEN', $token);
59
-        Log::addConfigurationLog($this->module->title() . ' : New token generated.');
59
+        Log::addConfigurationLog($this->module->title().' : New token generated.');
60 60
 
61 61
         return response(['token' => $token]);
62 62
     }
Please login to merge, or discard this patch.
app/Module/AdminTasks/Schema/Migration1.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 admin tasks table if it exists
35 35
         DB::schema()->dropIfExists('maj_admintasks');
36 36
 
37
-        DB::schema()->create('maj_admintasks', static function (Blueprint $table): void {
37
+        DB::schema()->create('maj_admintasks', static function(Blueprint $table): void {
38 38
 
39 39
             $table->increments('majat_id');
40 40
             $table->string('majat_task_id', 32)->unique();
Please login to merge, or discard this patch.
Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -25,31 +25,31 @@
 block discarded – undo
25 25
  */
26 26
 class Migration1 implements MigrationInterface
27 27
 {
28
-    /**
29
-     * {@inheritDoc}
30
-     * @see \Fisharebest\Webtrees\Schema\MigrationInterface::upgrade()
31
-     */
32
-    public function upgrade(): void
33
-    {
34
-        $in_transaction = DB::connection()->getPdo()->inTransaction();
35
-
36
-        // Clean up previous admin tasks table if it exists
37
-        DB::schema()->dropIfExists('maj_admintasks');
38
-
39
-        DB::schema()->create('maj_admintasks', static function (Blueprint $table): void {
40
-
41
-            $table->increments('majat_id');
42
-            $table->string('majat_task_id', 32)->unique();
43
-            $table->enum('majat_status', ['enabled', 'disabled'])->default('disabled');
44
-            $table->dateTime('majat_last_run')->default(Carbon::createFromTimestampUTC(0));
45
-            $table->boolean('majat_last_result')->default(true);
46
-            $table->integer('majat_frequency')->default(10080);
47
-            $table->smallInteger('majat_nb_occur')->default(0);
48
-            $table->boolean('majat_running')->default(false);
49
-        });
50
-
51
-        if ($in_transaction && !DB::connection()->getPdo()->inTransaction()) {
52
-            DB::connection()->beginTransaction();
53
-        }
54
-    }
28
+	/**
29
+	 * {@inheritDoc}
30
+	 * @see \Fisharebest\Webtrees\Schema\MigrationInterface::upgrade()
31
+	 */
32
+	public function upgrade(): void
33
+	{
34
+		$in_transaction = DB::connection()->getPdo()->inTransaction();
35
+
36
+		// Clean up previous admin tasks table if it exists
37
+		DB::schema()->dropIfExists('maj_admintasks');
38
+
39
+		DB::schema()->create('maj_admintasks', static function (Blueprint $table): void {
40
+
41
+			$table->increments('majat_id');
42
+			$table->string('majat_task_id', 32)->unique();
43
+			$table->enum('majat_status', ['enabled', 'disabled'])->default('disabled');
44
+			$table->dateTime('majat_last_run')->default(Carbon::createFromTimestampUTC(0));
45
+			$table->boolean('majat_last_result')->default(true);
46
+			$table->integer('majat_frequency')->default(10080);
47
+			$table->smallInteger('majat_nb_occur')->default(0);
48
+			$table->boolean('majat_running')->default(false);
49
+		});
50
+
51
+		if ($in_transaction && !DB::connection()->getPdo()->inTransaction()) {
52
+			DB::connection()->beginTransaction();
53
+		}
54
+	}
55 55
 }
Please login to merge, or discard this patch.