@@ -26,61 +26,61 @@ |
||
26 | 26 | */ |
27 | 27 | class NullPlaceMapperConfig implements PlaceMapperConfigInterface |
28 | 28 | { |
29 | - /** |
|
30 | - * {@inheritDoc} |
|
31 | - * @see \MyArtJaub\Webtrees\Contracts\GeoDispersion\PlaceMapperConfigInterface::get() |
|
32 | - */ |
|
33 | - public function get(string $key, $default = null) |
|
34 | - { |
|
35 | - return $default; |
|
36 | - } |
|
29 | + /** |
|
30 | + * {@inheritDoc} |
|
31 | + * @see \MyArtJaub\Webtrees\Contracts\GeoDispersion\PlaceMapperConfigInterface::get() |
|
32 | + */ |
|
33 | + public function get(string $key, $default = null) |
|
34 | + { |
|
35 | + return $default; |
|
36 | + } |
|
37 | 37 | |
38 | - /** |
|
39 | - * {@inheritDoc} |
|
40 | - * @see \MyArtJaub\Webtrees\Contracts\GeoDispersion\PlaceMapperConfigInterface::has() |
|
41 | - */ |
|
42 | - public function has(string $key): bool |
|
43 | - { |
|
44 | - return false; |
|
45 | - } |
|
38 | + /** |
|
39 | + * {@inheritDoc} |
|
40 | + * @see \MyArtJaub\Webtrees\Contracts\GeoDispersion\PlaceMapperConfigInterface::has() |
|
41 | + */ |
|
42 | + public function has(string $key): bool |
|
43 | + { |
|
44 | + return false; |
|
45 | + } |
|
46 | 46 | |
47 | - /** |
|
48 | - * {@inheritDoc} |
|
49 | - * @see \MyArtJaub\Webtrees\Contracts\GeoDispersion\PlaceMapperConfigInterface::jsonDeserialize() |
|
50 | - * |
|
51 | - * @param mixed $config |
|
52 | - * @return $this |
|
53 | - */ |
|
54 | - public function jsonDeserialize($config): self |
|
55 | - { |
|
56 | - return $this; |
|
57 | - } |
|
47 | + /** |
|
48 | + * {@inheritDoc} |
|
49 | + * @see \MyArtJaub\Webtrees\Contracts\GeoDispersion\PlaceMapperConfigInterface::jsonDeserialize() |
|
50 | + * |
|
51 | + * @param mixed $config |
|
52 | + * @return $this |
|
53 | + */ |
|
54 | + public function jsonDeserialize($config): self |
|
55 | + { |
|
56 | + return $this; |
|
57 | + } |
|
58 | 58 | |
59 | - /** |
|
60 | - * {@inheritDoc} |
|
61 | - * @see JsonSerializable::jsonSerialize() |
|
62 | - */ |
|
63 | - public function jsonSerialize() |
|
64 | - { |
|
65 | - return []; |
|
66 | - } |
|
59 | + /** |
|
60 | + * {@inheritDoc} |
|
61 | + * @see JsonSerializable::jsonSerialize() |
|
62 | + */ |
|
63 | + public function jsonSerialize() |
|
64 | + { |
|
65 | + return []; |
|
66 | + } |
|
67 | 67 | |
68 | - /** |
|
69 | - * {@inheritDoc} |
|
70 | - * @see \MyArtJaub\Webtrees\Contracts\GeoDispersion\PlaceMapperConfigInterface::configContent() |
|
71 | - */ |
|
72 | - public function configContent(ModuleInterface $module, Tree $tree): string |
|
73 | - { |
|
74 | - return ''; |
|
75 | - } |
|
68 | + /** |
|
69 | + * {@inheritDoc} |
|
70 | + * @see \MyArtJaub\Webtrees\Contracts\GeoDispersion\PlaceMapperConfigInterface::configContent() |
|
71 | + */ |
|
72 | + public function configContent(ModuleInterface $module, Tree $tree): string |
|
73 | + { |
|
74 | + return ''; |
|
75 | + } |
|
76 | 76 | |
77 | - /** |
|
78 | - * {@inheritDoc} |
|
79 | - * @see \MyArtJaub\Webtrees\Contracts\GeoDispersion\PlaceMapperConfigInterface::withConfigUpdate() |
|
80 | - * @return $this |
|
81 | - */ |
|
82 | - public function withConfigUpdate(ServerRequestInterface $request): self |
|
83 | - { |
|
84 | - return $this; |
|
85 | - } |
|
77 | + /** |
|
78 | + * {@inheritDoc} |
|
79 | + * @see \MyArtJaub\Webtrees\Contracts\GeoDispersion\PlaceMapperConfigInterface::withConfigUpdate() |
|
80 | + * @return $this |
|
81 | + */ |
|
82 | + public function withConfigUpdate(ServerRequestInterface $request): self |
|
83 | + { |
|
84 | + return $this; |
|
85 | + } |
|
86 | 86 | } |
@@ -23,51 +23,51 @@ |
||
23 | 23 | */ |
24 | 24 | class MapViewConfig implements MapViewConfigInterface |
25 | 25 | { |
26 | - private string $map_mapping_property; |
|
27 | - private PlaceMapperConfigInterface $mapper_config; |
|
26 | + private string $map_mapping_property; |
|
27 | + private PlaceMapperConfigInterface $mapper_config; |
|
28 | 28 | |
29 | - /** |
|
30 | - * Constructor for MapViewConfig |
|
31 | - * |
|
32 | - * @param string $map_mapping_property |
|
33 | - * @param PlaceMapperConfigInterface $mapper_config |
|
34 | - */ |
|
35 | - public function __construct( |
|
36 | - string $map_mapping_property, |
|
37 | - PlaceMapperConfigInterface $mapper_config = null |
|
38 | - ) { |
|
39 | - $this->map_mapping_property = $map_mapping_property; |
|
40 | - $this->mapper_config = $mapper_config ?? new NullPlaceMapperConfig(); |
|
41 | - } |
|
29 | + /** |
|
30 | + * Constructor for MapViewConfig |
|
31 | + * |
|
32 | + * @param string $map_mapping_property |
|
33 | + * @param PlaceMapperConfigInterface $mapper_config |
|
34 | + */ |
|
35 | + public function __construct( |
|
36 | + string $map_mapping_property, |
|
37 | + PlaceMapperConfigInterface $mapper_config = null |
|
38 | + ) { |
|
39 | + $this->map_mapping_property = $map_mapping_property; |
|
40 | + $this->mapper_config = $mapper_config ?? new NullPlaceMapperConfig(); |
|
41 | + } |
|
42 | 42 | |
43 | - /** |
|
44 | - * {@inheritDoc} |
|
45 | - * @see \MyArtJaub\Webtrees\Contracts\GeoDispersion\MapViewConfigInterface::mapMappingProperty() |
|
46 | - */ |
|
47 | - public function mapMappingProperty(): string |
|
48 | - { |
|
49 | - return $this->map_mapping_property; |
|
50 | - } |
|
43 | + /** |
|
44 | + * {@inheritDoc} |
|
45 | + * @see \MyArtJaub\Webtrees\Contracts\GeoDispersion\MapViewConfigInterface::mapMappingProperty() |
|
46 | + */ |
|
47 | + public function mapMappingProperty(): string |
|
48 | + { |
|
49 | + return $this->map_mapping_property; |
|
50 | + } |
|
51 | 51 | |
52 | - /** |
|
53 | - * {@inheritDoc} |
|
54 | - * @see \MyArtJaub\Webtrees\Contracts\GeoDispersion\MapViewConfigInterface::mapperConfig() |
|
55 | - */ |
|
56 | - public function mapperConfig(): PlaceMapperConfigInterface |
|
57 | - { |
|
58 | - return $this->mapper_config; |
|
59 | - } |
|
52 | + /** |
|
53 | + * {@inheritDoc} |
|
54 | + * @see \MyArtJaub\Webtrees\Contracts\GeoDispersion\MapViewConfigInterface::mapperConfig() |
|
55 | + */ |
|
56 | + public function mapperConfig(): PlaceMapperConfigInterface |
|
57 | + { |
|
58 | + return $this->mapper_config; |
|
59 | + } |
|
60 | 60 | |
61 | - /** |
|
62 | - * {@inheritDoc} |
|
63 | - * @see \MyArtJaub\Webtrees\Contracts\GeoDispersion\MapViewConfigInterface::with() |
|
64 | - * @return static |
|
65 | - */ |
|
66 | - public function with(string $mapping_property, PlaceMapperConfigInterface $mapper_config): self |
|
67 | - { |
|
68 | - $new = clone $this; |
|
69 | - $new->map_mapping_property = $mapping_property; |
|
70 | - $new->mapper_config = $mapper_config; |
|
71 | - return $new; |
|
72 | - } |
|
61 | + /** |
|
62 | + * {@inheritDoc} |
|
63 | + * @see \MyArtJaub\Webtrees\Contracts\GeoDispersion\MapViewConfigInterface::with() |
|
64 | + * @return static |
|
65 | + */ |
|
66 | + public function with(string $mapping_property, PlaceMapperConfigInterface $mapper_config): self |
|
67 | + { |
|
68 | + $new = clone $this; |
|
69 | + $new->map_mapping_property = $mapping_property; |
|
70 | + $new->mapper_config = $mapper_config; |
|
71 | + return $new; |
|
72 | + } |
|
73 | 73 | } |
@@ -32,129 +32,129 @@ |
||
32 | 32 | */ |
33 | 33 | class CertificateFilesystemService |
34 | 34 | { |
35 | - /** |
|
36 | - * @var array<int,FilesystemOperator> $filesystem |
|
37 | - */ |
|
38 | - private array $filesystem = []; |
|
35 | + /** |
|
36 | + * @var array<int,FilesystemOperator> $filesystem |
|
37 | + */ |
|
38 | + private array $filesystem = []; |
|
39 | 39 | |
40 | - /** |
|
41 | - * Get the filesystem containing certificates for a tree. |
|
42 | - * |
|
43 | - * @param Tree $tree |
|
44 | - * @return FilesystemOperator |
|
45 | - */ |
|
46 | - public function filesystem(Tree $tree): FilesystemOperator |
|
47 | - { |
|
48 | - if (!isset($this->filesystem[$tree->id()])) { |
|
49 | - $cert_dir = $tree->getPreference('MAJ_CERTIF_ROOTDIR', 'certificates/'); |
|
50 | - $adapter = new ChrootAdapter(Registry::filesystem()->data(), $cert_dir); |
|
40 | + /** |
|
41 | + * Get the filesystem containing certificates for a tree. |
|
42 | + * |
|
43 | + * @param Tree $tree |
|
44 | + * @return FilesystemOperator |
|
45 | + */ |
|
46 | + public function filesystem(Tree $tree): FilesystemOperator |
|
47 | + { |
|
48 | + if (!isset($this->filesystem[$tree->id()])) { |
|
49 | + $cert_dir = $tree->getPreference('MAJ_CERTIF_ROOTDIR', 'certificates/'); |
|
50 | + $adapter = new ChrootAdapter(Registry::filesystem()->data(), $cert_dir); |
|
51 | 51 | |
52 | - $this->filesystem[$tree->id()] = new FileSystem($adapter); |
|
53 | - } |
|
54 | - return $this->filesystem[$tree->id()]; |
|
55 | - } |
|
52 | + $this->filesystem[$tree->id()] = new FileSystem($adapter); |
|
53 | + } |
|
54 | + return $this->filesystem[$tree->id()]; |
|
55 | + } |
|
56 | 56 | |
57 | - /** |
|
58 | - * Set the filesystem containing certificates for a tree. |
|
59 | - * |
|
60 | - * @param Tree $tree |
|
61 | - * @param FilesystemOperator $filesystem |
|
62 | - */ |
|
63 | - public function setFilesystem(Tree $tree, FilesystemOperator $filesystem): void |
|
64 | - { |
|
65 | - $this->filesystem[$tree->id()] = $filesystem; |
|
66 | - } |
|
57 | + /** |
|
58 | + * Set the filesystem containing certificates for a tree. |
|
59 | + * |
|
60 | + * @param Tree $tree |
|
61 | + * @param FilesystemOperator $filesystem |
|
62 | + */ |
|
63 | + public function setFilesystem(Tree $tree, FilesystemOperator $filesystem): void |
|
64 | + { |
|
65 | + $this->filesystem[$tree->id()] = $filesystem; |
|
66 | + } |
|
67 | 67 | |
68 | - /** |
|
69 | - * Create the Certificate object defined by a path on the filesystem. |
|
70 | - * |
|
71 | - * @param Tree $tree |
|
72 | - * @param string $path |
|
73 | - * @return Certificate|NULL |
|
74 | - */ |
|
75 | - public function certificate(Tree $tree, string $path): ?Certificate |
|
76 | - { |
|
77 | - $filesystem = $this->filesystem($tree); |
|
78 | - if ($filesystem->fileExists($path) && $this->isFileSupported($filesystem, $path)) { |
|
79 | - return new Certificate($tree, $path); |
|
80 | - } |
|
81 | - return null; |
|
82 | - } |
|
68 | + /** |
|
69 | + * Create the Certificate object defined by a path on the filesystem. |
|
70 | + * |
|
71 | + * @param Tree $tree |
|
72 | + * @param string $path |
|
73 | + * @return Certificate|NULL |
|
74 | + */ |
|
75 | + public function certificate(Tree $tree, string $path): ?Certificate |
|
76 | + { |
|
77 | + $filesystem = $this->filesystem($tree); |
|
78 | + if ($filesystem->fileExists($path) && $this->isFileSupported($filesystem, $path)) { |
|
79 | + return new Certificate($tree, $path); |
|
80 | + } |
|
81 | + return null; |
|
82 | + } |
|
83 | 83 | |
84 | - /** |
|
85 | - * Get the cities (first-level folder) available in a the filesystem. |
|
86 | - * |
|
87 | - * @param Tree $tree |
|
88 | - * @return string[] |
|
89 | - */ |
|
90 | - public function cities(Tree $tree): array |
|
91 | - { |
|
92 | - $cities = $this->filesystem($tree) |
|
93 | - ->listContents('') |
|
94 | - ->filter(fn (StorageAttributes $attributes): bool => $attributes->isDir()) |
|
95 | - ->map(fn (StorageAttributes $attributes): string => $attributes->path()) |
|
96 | - ->toArray(); |
|
97 | - usort($cities, I18N::comparator()); |
|
98 | - return $cities; |
|
99 | - } |
|
84 | + /** |
|
85 | + * Get the cities (first-level folder) available in a the filesystem. |
|
86 | + * |
|
87 | + * @param Tree $tree |
|
88 | + * @return string[] |
|
89 | + */ |
|
90 | + public function cities(Tree $tree): array |
|
91 | + { |
|
92 | + $cities = $this->filesystem($tree) |
|
93 | + ->listContents('') |
|
94 | + ->filter(fn (StorageAttributes $attributes): bool => $attributes->isDir()) |
|
95 | + ->map(fn (StorageAttributes $attributes): string => $attributes->path()) |
|
96 | + ->toArray(); |
|
97 | + usort($cities, I18N::comparator()); |
|
98 | + return $cities; |
|
99 | + } |
|
100 | 100 | |
101 | - /** |
|
102 | - * Get the certificates available for a city (first-level folder). |
|
103 | - * |
|
104 | - * @param Tree $tree |
|
105 | - * @param string $city |
|
106 | - * @return Collection<Certificate> |
|
107 | - */ |
|
108 | - public function certificatesForCity(Tree $tree, string $city): Collection |
|
109 | - { |
|
110 | - $filesystem = $this->filesystem($tree); |
|
111 | - $certificates_paths = $filesystem->listContents($city) |
|
112 | - ->filter(fn (StorageAttributes $attributes): bool => |
|
113 | - $attributes->isFile() && $this->isFileSupported($filesystem, $attributes->path())) |
|
114 | - ->map(fn (StorageAttributes $attributes): string => $attributes->path()) |
|
115 | - ->toArray(); |
|
116 | - usort($certificates_paths, I18N::comparator()); |
|
117 | - return collect($certificates_paths)->map(fn (string $path): Certificate => new Certificate($tree, $path)); |
|
118 | - } |
|
101 | + /** |
|
102 | + * Get the certificates available for a city (first-level folder). |
|
103 | + * |
|
104 | + * @param Tree $tree |
|
105 | + * @param string $city |
|
106 | + * @return Collection<Certificate> |
|
107 | + */ |
|
108 | + public function certificatesForCity(Tree $tree, string $city): Collection |
|
109 | + { |
|
110 | + $filesystem = $this->filesystem($tree); |
|
111 | + $certificates_paths = $filesystem->listContents($city) |
|
112 | + ->filter(fn (StorageAttributes $attributes): bool => |
|
113 | + $attributes->isFile() && $this->isFileSupported($filesystem, $attributes->path())) |
|
114 | + ->map(fn (StorageAttributes $attributes): string => $attributes->path()) |
|
115 | + ->toArray(); |
|
116 | + usort($certificates_paths, I18N::comparator()); |
|
117 | + return collect($certificates_paths)->map(fn (string $path): Certificate => new Certificate($tree, $path)); |
|
118 | + } |
|
119 | 119 | |
120 | - /** |
|
121 | - * Get the certificates available for a city (first-level folder), containing a specified text. |
|
122 | - * |
|
123 | - * @param Tree $tree |
|
124 | - * @param string $city |
|
125 | - * @param string $contains |
|
126 | - * @return Collection<Certificate> |
|
127 | - */ |
|
128 | - public function certificatesForCityContaining(Tree $tree, string $city, string $contains): Collection |
|
129 | - { |
|
130 | - $filesystem = $this->filesystem($tree); |
|
131 | - $certificates_paths = $filesystem->listContents($city) |
|
132 | - ->filter(fn (StorageAttributes $attributes): bool => |
|
133 | - $attributes->isFile() && $this->isFileSupported($filesystem, $attributes->path()) |
|
134 | - && mb_stripos($attributes->path(), $contains) !== false) |
|
135 | - ->map(fn (StorageAttributes $attributes): string => $attributes->path()) |
|
136 | - ->toArray(); |
|
137 | - usort($certificates_paths, I18N::comparator()); |
|
138 | - return collect($certificates_paths)->map(fn (string $path): Certificate => new Certificate($tree, $path)); |
|
139 | - } |
|
120 | + /** |
|
121 | + * Get the certificates available for a city (first-level folder), containing a specified text. |
|
122 | + * |
|
123 | + * @param Tree $tree |
|
124 | + * @param string $city |
|
125 | + * @param string $contains |
|
126 | + * @return Collection<Certificate> |
|
127 | + */ |
|
128 | + public function certificatesForCityContaining(Tree $tree, string $city, string $contains): Collection |
|
129 | + { |
|
130 | + $filesystem = $this->filesystem($tree); |
|
131 | + $certificates_paths = $filesystem->listContents($city) |
|
132 | + ->filter(fn (StorageAttributes $attributes): bool => |
|
133 | + $attributes->isFile() && $this->isFileSupported($filesystem, $attributes->path()) |
|
134 | + && mb_stripos($attributes->path(), $contains) !== false) |
|
135 | + ->map(fn (StorageAttributes $attributes): string => $attributes->path()) |
|
136 | + ->toArray(); |
|
137 | + usort($certificates_paths, I18N::comparator()); |
|
138 | + return collect($certificates_paths)->map(fn (string $path): Certificate => new Certificate($tree, $path)); |
|
139 | + } |
|
140 | 140 | |
141 | - /** |
|
142 | - * Check if a file on the filesystem is supported by the certificate module. |
|
143 | - * |
|
144 | - * @param FilesystemOperator $filesystem |
|
145 | - * @param string $path |
|
146 | - * @return bool |
|
147 | - */ |
|
148 | - protected function isFileSupported(FilesystemOperator $filesystem, string $path): bool |
|
149 | - { |
|
150 | - try { |
|
151 | - $mime = $filesystem->mimeType($path); |
|
152 | - return Registry::cache()->array()->remember( |
|
153 | - 'maj-certif-supportedfiles-' . $mime, |
|
154 | - fn (): bool => app(CertificateImageFactory::class)->isMimeTypeSupported($mime) |
|
155 | - ); |
|
156 | - } catch (UnableToRetrieveMetadata | FilesystemException $ex) { |
|
157 | - } |
|
158 | - return false; |
|
159 | - } |
|
141 | + /** |
|
142 | + * Check if a file on the filesystem is supported by the certificate module. |
|
143 | + * |
|
144 | + * @param FilesystemOperator $filesystem |
|
145 | + * @param string $path |
|
146 | + * @return bool |
|
147 | + */ |
|
148 | + protected function isFileSupported(FilesystemOperator $filesystem, string $path): bool |
|
149 | + { |
|
150 | + try { |
|
151 | + $mime = $filesystem->mimeType($path); |
|
152 | + return Registry::cache()->array()->remember( |
|
153 | + 'maj-certif-supportedfiles-' . $mime, |
|
154 | + fn (): bool => app(CertificateImageFactory::class)->isMimeTypeSupported($mime) |
|
155 | + ); |
|
156 | + } catch (UnableToRetrieveMetadata | FilesystemException $ex) { |
|
157 | + } |
|
158 | + return false; |
|
159 | + } |
|
160 | 160 | } |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | { |
48 | 48 | if (!isset($this->filesystem[$tree->id()])) { |
49 | 49 | $cert_dir = $tree->getPreference('MAJ_CERTIF_ROOTDIR', 'certificates/'); |
50 | - $adapter = new ChrootAdapter(Registry::filesystem()->data(), $cert_dir); |
|
50 | + $adapter = new ChrootAdapter(Registry::filesystem()->data(), $cert_dir); |
|
51 | 51 | |
52 | 52 | $this->filesystem[$tree->id()] = new FileSystem($adapter); |
53 | 53 | } |
@@ -89,10 +89,10 @@ discard block |
||
89 | 89 | */ |
90 | 90 | public function cities(Tree $tree): array |
91 | 91 | { |
92 | - $cities = $this->filesystem($tree) |
|
92 | + $cities = $this->filesystem($tree) |
|
93 | 93 | ->listContents('') |
94 | - ->filter(fn (StorageAttributes $attributes): bool => $attributes->isDir()) |
|
95 | - ->map(fn (StorageAttributes $attributes): string => $attributes->path()) |
|
94 | + ->filter(fn(StorageAttributes $attributes): bool => $attributes->isDir()) |
|
95 | + ->map(fn(StorageAttributes $attributes): string => $attributes->path()) |
|
96 | 96 | ->toArray(); |
97 | 97 | usort($cities, I18N::comparator()); |
98 | 98 | return $cities; |
@@ -109,12 +109,12 @@ discard block |
||
109 | 109 | { |
110 | 110 | $filesystem = $this->filesystem($tree); |
111 | 111 | $certificates_paths = $filesystem->listContents($city) |
112 | - ->filter(fn (StorageAttributes $attributes): bool => |
|
112 | + ->filter(fn(StorageAttributes $attributes): bool => |
|
113 | 113 | $attributes->isFile() && $this->isFileSupported($filesystem, $attributes->path())) |
114 | - ->map(fn (StorageAttributes $attributes): string => $attributes->path()) |
|
114 | + ->map(fn(StorageAttributes $attributes): string => $attributes->path()) |
|
115 | 115 | ->toArray(); |
116 | 116 | usort($certificates_paths, I18N::comparator()); |
117 | - return collect($certificates_paths)->map(fn (string $path): Certificate => new Certificate($tree, $path)); |
|
117 | + return collect($certificates_paths)->map(fn(string $path): Certificate => new Certificate($tree, $path)); |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | /** |
@@ -129,13 +129,13 @@ discard block |
||
129 | 129 | { |
130 | 130 | $filesystem = $this->filesystem($tree); |
131 | 131 | $certificates_paths = $filesystem->listContents($city) |
132 | - ->filter(fn (StorageAttributes $attributes): bool => |
|
132 | + ->filter(fn(StorageAttributes $attributes): bool => |
|
133 | 133 | $attributes->isFile() && $this->isFileSupported($filesystem, $attributes->path()) |
134 | 134 | && mb_stripos($attributes->path(), $contains) !== false) |
135 | - ->map(fn (StorageAttributes $attributes): string => $attributes->path()) |
|
135 | + ->map(fn(StorageAttributes $attributes): string => $attributes->path()) |
|
136 | 136 | ->toArray(); |
137 | 137 | usort($certificates_paths, I18N::comparator()); |
138 | - return collect($certificates_paths)->map(fn (string $path): Certificate => new Certificate($tree, $path)); |
|
138 | + return collect($certificates_paths)->map(fn(string $path): Certificate => new Certificate($tree, $path)); |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | /** |
@@ -150,8 +150,8 @@ discard block |
||
150 | 150 | try { |
151 | 151 | $mime = $filesystem->mimeType($path); |
152 | 152 | return Registry::cache()->array()->remember( |
153 | - 'maj-certif-supportedfiles-' . $mime, |
|
154 | - fn (): bool => app(CertificateImageFactory::class)->isMimeTypeSupported($mime) |
|
153 | + 'maj-certif-supportedfiles-'.$mime, |
|
154 | + fn(): bool => app(CertificateImageFactory::class)->isMimeTypeSupported($mime) |
|
155 | 155 | ); |
156 | 156 | } catch (UnableToRetrieveMetadata | FilesystemException $ex) { |
157 | 157 | } |
@@ -21,19 +21,19 @@ |
||
21 | 21 | */ |
22 | 22 | interface ModuleMyArtJaubInterface extends ModuleCustomInterface |
23 | 23 | { |
24 | - /** |
|
25 | - * Add module routes to webtrees route loader |
|
26 | - * |
|
27 | - * @param Map<\Aura\Router\Route> $router |
|
28 | - */ |
|
29 | - public function loadRoutes(Map $router): void; |
|
24 | + /** |
|
25 | + * Add module routes to webtrees route loader |
|
26 | + * |
|
27 | + * @param Map<\Aura\Router\Route> $router |
|
28 | + */ |
|
29 | + public function loadRoutes(Map $router): void; |
|
30 | 30 | |
31 | - /** |
|
32 | - * Returns the URL of the module specific stylesheets. |
|
33 | - * It will look for a CSS file matching the theme name (e.g. xenea.min.css), |
|
34 | - * and fallback to default.min.css if none are found |
|
35 | - * |
|
36 | - * @return string |
|
37 | - */ |
|
38 | - public function moduleCssUrl(): string; |
|
31 | + /** |
|
32 | + * Returns the URL of the module specific stylesheets. |
|
33 | + * It will look for a CSS file matching the theme name (e.g. xenea.min.css), |
|
34 | + * and fallback to default.min.css if none are found |
|
35 | + * |
|
36 | + * @return string |
|
37 | + */ |
|
38 | + public function moduleCssUrl(): string; |
|
39 | 39 | } |
@@ -30,126 +30,126 @@ |
||
30 | 30 | class SourceStatusService |
31 | 31 | { |
32 | 32 | |
33 | - /** |
|
34 | - * Maximum timespan between the date of a source and the date of the event to consider the source precise. |
|
35 | - * Arbitrally set to approximately a year around the event date. |
|
36 | - * |
|
37 | - * @var int DATE_PRECISION_MARGIN |
|
38 | - */ |
|
39 | - private const DATE_PRECISION_MARGIN = 180; |
|
40 | - |
|
41 | - /** |
|
42 | - * Return the status of source citations for a fact. |
|
43 | - * |
|
44 | - * @param Fact $fact |
|
45 | - * @return FactSourceStatus |
|
46 | - */ |
|
47 | - public function sourceStatusForFact(Fact $fact): FactSourceStatus |
|
48 | - { |
|
49 | - $source_status = new FactSourceStatus(); |
|
50 | - |
|
51 | - $date = $fact->date(); |
|
52 | - $source_status |
|
53 | - ->setFactHasDate($date->isOK()) |
|
54 | - ->setFactHasPreciseDate($date->qual1 === '' && $date->minimumJulianDay() === $date->maximumJulianDay()); |
|
55 | - |
|
56 | - foreach ($fact->getCitations() as $citation) { |
|
57 | - $source_status |
|
58 | - ->setHasSource(true) |
|
59 | - ->addHasSupportingDocument(preg_match('/\n3 _ACT (?:.*)/', $citation) === 1); |
|
60 | - |
|
61 | - preg_match_all("/\n3 DATA(?:\n[4-9] .*)*\n4 DATE (.*)/", $citation, $date_matches, PREG_SET_ORDER); |
|
62 | - foreach ($date_matches as $date_match) { |
|
63 | - $source_date = new Date($date_match[1]); |
|
64 | - $source_status |
|
65 | - ->addSourceHasDate($source_date->isOK()) |
|
66 | - ->addSourceMatchesFactDate($date->isOK() && $source_date->isOK() |
|
67 | - && abs($source_date->julianDay() - $date->julianDay()) < self::DATE_PRECISION_MARGIN); |
|
68 | - } |
|
69 | - |
|
70 | - if ($source_status->isFullySourced()) { |
|
71 | - return $source_status; |
|
72 | - } |
|
73 | - } |
|
74 | - |
|
75 | - return $source_status; |
|
76 | - } |
|
77 | - |
|
78 | - /** |
|
79 | - * Return the status of sources for a Gedcom record. |
|
80 | - * |
|
81 | - * @param GedcomRecord $record |
|
82 | - * @return SourceStatus |
|
83 | - */ |
|
84 | - public function sourceStatusForRecord(GedcomRecord $record): SourceStatus |
|
85 | - { |
|
86 | - $source_status = new SourceStatus(); |
|
87 | - |
|
88 | - foreach ($record->facts(['SOUR']) as $source) { |
|
89 | - $source_status |
|
90 | - ->setHasSource(true) |
|
91 | - ->addHasSupportingDocument($source->attribute('_ACT') !== ''); |
|
92 | - |
|
93 | - if ($source_status->isFullySourced()) { |
|
94 | - return $source_status; |
|
95 | - } |
|
96 | - } |
|
97 | - |
|
98 | - return $source_status; |
|
99 | - } |
|
100 | - |
|
101 | - /** |
|
102 | - * Return the status of source citations for a list of fact types associated with a record. |
|
103 | - * |
|
104 | - * @param GedcomRecord $record |
|
105 | - * @param string[] $tags |
|
106 | - * @return FactSourceStatus |
|
107 | - */ |
|
108 | - public function sourceStatusForFactsWithTags(GedcomRecord $record, array $tags): FactSourceStatus |
|
109 | - { |
|
110 | - $source_status = new NullFactSourceStatus(); |
|
111 | - |
|
112 | - foreach ($record->facts($tags) as $fact) { |
|
113 | - $source_status = $source_status->combineWith($this->sourceStatusForFact($fact)); |
|
114 | - if ($source_status->isFullySourced()) { |
|
115 | - return $source_status; |
|
116 | - } |
|
117 | - } |
|
118 | - |
|
119 | - return $source_status; |
|
120 | - } |
|
121 | - |
|
122 | - /** |
|
123 | - * Return the status of source citations for an individual's birth events. |
|
124 | - * |
|
125 | - * @param Individual $individual |
|
126 | - * @return FactSourceStatus |
|
127 | - */ |
|
128 | - public function sourceStatusForBirth(Individual $individual): FactSourceStatus |
|
129 | - { |
|
130 | - return $this->sourceStatusForFactsWithTags($individual, Gedcom::BIRTH_EVENTS); |
|
131 | - } |
|
132 | - |
|
133 | - /** |
|
134 | - * Return the status of source citations for an individual's death events. |
|
135 | - * |
|
136 | - * @param Individual $individual |
|
137 | - * @return FactSourceStatus |
|
138 | - */ |
|
139 | - public function sourceStatusForDeath(Individual $individual): FactSourceStatus |
|
140 | - { |
|
141 | - return $this->sourceStatusForFactsWithTags($individual, Gedcom::DEATH_EVENTS); |
|
142 | - } |
|
143 | - |
|
144 | - /** |
|
145 | - * Return the status of source citations for a family's marriage events. |
|
146 | - * |
|
147 | - * @param Family $family |
|
148 | - * @return FactSourceStatus |
|
149 | - */ |
|
150 | - public function sourceStatusForMarriage(Family $family): FactSourceStatus |
|
151 | - { |
|
152 | - $marr_events = array_merge(Gedcom::MARRIAGE_EVENTS, ['MARC', 'MARL', 'MARS']); |
|
153 | - return $this->sourceStatusForFactsWithTags($family, $marr_events); |
|
154 | - } |
|
33 | + /** |
|
34 | + * Maximum timespan between the date of a source and the date of the event to consider the source precise. |
|
35 | + * Arbitrally set to approximately a year around the event date. |
|
36 | + * |
|
37 | + * @var int DATE_PRECISION_MARGIN |
|
38 | + */ |
|
39 | + private const DATE_PRECISION_MARGIN = 180; |
|
40 | + |
|
41 | + /** |
|
42 | + * Return the status of source citations for a fact. |
|
43 | + * |
|
44 | + * @param Fact $fact |
|
45 | + * @return FactSourceStatus |
|
46 | + */ |
|
47 | + public function sourceStatusForFact(Fact $fact): FactSourceStatus |
|
48 | + { |
|
49 | + $source_status = new FactSourceStatus(); |
|
50 | + |
|
51 | + $date = $fact->date(); |
|
52 | + $source_status |
|
53 | + ->setFactHasDate($date->isOK()) |
|
54 | + ->setFactHasPreciseDate($date->qual1 === '' && $date->minimumJulianDay() === $date->maximumJulianDay()); |
|
55 | + |
|
56 | + foreach ($fact->getCitations() as $citation) { |
|
57 | + $source_status |
|
58 | + ->setHasSource(true) |
|
59 | + ->addHasSupportingDocument(preg_match('/\n3 _ACT (?:.*)/', $citation) === 1); |
|
60 | + |
|
61 | + preg_match_all("/\n3 DATA(?:\n[4-9] .*)*\n4 DATE (.*)/", $citation, $date_matches, PREG_SET_ORDER); |
|
62 | + foreach ($date_matches as $date_match) { |
|
63 | + $source_date = new Date($date_match[1]); |
|
64 | + $source_status |
|
65 | + ->addSourceHasDate($source_date->isOK()) |
|
66 | + ->addSourceMatchesFactDate($date->isOK() && $source_date->isOK() |
|
67 | + && abs($source_date->julianDay() - $date->julianDay()) < self::DATE_PRECISION_MARGIN); |
|
68 | + } |
|
69 | + |
|
70 | + if ($source_status->isFullySourced()) { |
|
71 | + return $source_status; |
|
72 | + } |
|
73 | + } |
|
74 | + |
|
75 | + return $source_status; |
|
76 | + } |
|
77 | + |
|
78 | + /** |
|
79 | + * Return the status of sources for a Gedcom record. |
|
80 | + * |
|
81 | + * @param GedcomRecord $record |
|
82 | + * @return SourceStatus |
|
83 | + */ |
|
84 | + public function sourceStatusForRecord(GedcomRecord $record): SourceStatus |
|
85 | + { |
|
86 | + $source_status = new SourceStatus(); |
|
87 | + |
|
88 | + foreach ($record->facts(['SOUR']) as $source) { |
|
89 | + $source_status |
|
90 | + ->setHasSource(true) |
|
91 | + ->addHasSupportingDocument($source->attribute('_ACT') !== ''); |
|
92 | + |
|
93 | + if ($source_status->isFullySourced()) { |
|
94 | + return $source_status; |
|
95 | + } |
|
96 | + } |
|
97 | + |
|
98 | + return $source_status; |
|
99 | + } |
|
100 | + |
|
101 | + /** |
|
102 | + * Return the status of source citations for a list of fact types associated with a record. |
|
103 | + * |
|
104 | + * @param GedcomRecord $record |
|
105 | + * @param string[] $tags |
|
106 | + * @return FactSourceStatus |
|
107 | + */ |
|
108 | + public function sourceStatusForFactsWithTags(GedcomRecord $record, array $tags): FactSourceStatus |
|
109 | + { |
|
110 | + $source_status = new NullFactSourceStatus(); |
|
111 | + |
|
112 | + foreach ($record->facts($tags) as $fact) { |
|
113 | + $source_status = $source_status->combineWith($this->sourceStatusForFact($fact)); |
|
114 | + if ($source_status->isFullySourced()) { |
|
115 | + return $source_status; |
|
116 | + } |
|
117 | + } |
|
118 | + |
|
119 | + return $source_status; |
|
120 | + } |
|
121 | + |
|
122 | + /** |
|
123 | + * Return the status of source citations for an individual's birth events. |
|
124 | + * |
|
125 | + * @param Individual $individual |
|
126 | + * @return FactSourceStatus |
|
127 | + */ |
|
128 | + public function sourceStatusForBirth(Individual $individual): FactSourceStatus |
|
129 | + { |
|
130 | + return $this->sourceStatusForFactsWithTags($individual, Gedcom::BIRTH_EVENTS); |
|
131 | + } |
|
132 | + |
|
133 | + /** |
|
134 | + * Return the status of source citations for an individual's death events. |
|
135 | + * |
|
136 | + * @param Individual $individual |
|
137 | + * @return FactSourceStatus |
|
138 | + */ |
|
139 | + public function sourceStatusForDeath(Individual $individual): FactSourceStatus |
|
140 | + { |
|
141 | + return $this->sourceStatusForFactsWithTags($individual, Gedcom::DEATH_EVENTS); |
|
142 | + } |
|
143 | + |
|
144 | + /** |
|
145 | + * Return the status of source citations for a family's marriage events. |
|
146 | + * |
|
147 | + * @param Family $family |
|
148 | + * @return FactSourceStatus |
|
149 | + */ |
|
150 | + public function sourceStatusForMarriage(Family $family): FactSourceStatus |
|
151 | + { |
|
152 | + $marr_events = array_merge(Gedcom::MARRIAGE_EVENTS, ['MARC', 'MARL', 'MARS']); |
|
153 | + return $this->sourceStatusForFactsWithTags($family, $marr_events); |
|
154 | + } |
|
155 | 155 | } |
@@ -25,41 +25,41 @@ |
||
25 | 25 | */ |
26 | 26 | class GeoAnalysisService |
27 | 27 | { |
28 | - private ModuleService $module_service; |
|
28 | + private ModuleService $module_service; |
|
29 | 29 | |
30 | - /** |
|
31 | - * Constructor for MapDefinitionsService |
|
32 | - * |
|
33 | - * @param ModuleService $module_service |
|
34 | - */ |
|
35 | - public function __construct(ModuleService $module_service) |
|
36 | - { |
|
37 | - $this->module_service = $module_service; |
|
38 | - } |
|
30 | + /** |
|
31 | + * Constructor for MapDefinitionsService |
|
32 | + * |
|
33 | + * @param ModuleService $module_service |
|
34 | + */ |
|
35 | + public function __construct(ModuleService $module_service) |
|
36 | + { |
|
37 | + $this->module_service = $module_service; |
|
38 | + } |
|
39 | 39 | |
40 | - /** |
|
41 | - * Get all available geographical dispersion analyses. |
|
42 | - * |
|
43 | - * {@internal The list is generated based on the modules exposing ModuleGeoAnalysisProviderInterface |
|
44 | - * |
|
45 | - * @param bool $include_disabled |
|
46 | - * @return Collection<GeoAnalysisInterface> |
|
47 | - */ |
|
48 | - public function all(bool $include_disabled = false): Collection |
|
49 | - { |
|
50 | - /** @var Collection<GeoAnalysisInterface> $geoanalyses */ |
|
51 | - $geoanalyses = $this->module_service |
|
52 | - ->findByInterface(ModuleGeoAnalysisProviderInterface::class, $include_disabled) |
|
53 | - ->flatMap(fn(ModuleGeoAnalysisProviderInterface $module) => $module->listGeoAnalyses()) |
|
54 | - ->map(static function (string $analysis_class): ?GeoAnalysisInterface { |
|
55 | - try { |
|
56 | - $analysis = app($analysis_class); |
|
57 | - return $analysis instanceof GeoAnalysisInterface ? $analysis : null; |
|
58 | - } catch (BindingResolutionException $ex) { |
|
59 | - return null; |
|
60 | - } |
|
61 | - })->filter(); |
|
40 | + /** |
|
41 | + * Get all available geographical dispersion analyses. |
|
42 | + * |
|
43 | + * {@internal The list is generated based on the modules exposing ModuleGeoAnalysisProviderInterface |
|
44 | + * |
|
45 | + * @param bool $include_disabled |
|
46 | + * @return Collection<GeoAnalysisInterface> |
|
47 | + */ |
|
48 | + public function all(bool $include_disabled = false): Collection |
|
49 | + { |
|
50 | + /** @var Collection<GeoAnalysisInterface> $geoanalyses */ |
|
51 | + $geoanalyses = $this->module_service |
|
52 | + ->findByInterface(ModuleGeoAnalysisProviderInterface::class, $include_disabled) |
|
53 | + ->flatMap(fn(ModuleGeoAnalysisProviderInterface $module) => $module->listGeoAnalyses()) |
|
54 | + ->map(static function (string $analysis_class): ?GeoAnalysisInterface { |
|
55 | + try { |
|
56 | + $analysis = app($analysis_class); |
|
57 | + return $analysis instanceof GeoAnalysisInterface ? $analysis : null; |
|
58 | + } catch (BindingResolutionException $ex) { |
|
59 | + return null; |
|
60 | + } |
|
61 | + })->filter(); |
|
62 | 62 | |
63 | - return $geoanalyses; |
|
64 | - } |
|
63 | + return $geoanalyses; |
|
64 | + } |
|
65 | 65 | } |
@@ -51,7 +51,7 @@ |
||
51 | 51 | $geoanalyses = $this->module_service |
52 | 52 | ->findByInterface(ModuleGeoAnalysisProviderInterface::class, $include_disabled) |
53 | 53 | ->flatMap(fn(ModuleGeoAnalysisProviderInterface $module) => $module->listGeoAnalyses()) |
54 | - ->map(static function (string $analysis_class): ?GeoAnalysisInterface { |
|
54 | + ->map(static function(string $analysis_class): ?GeoAnalysisInterface { |
|
55 | 55 | try { |
56 | 56 | $analysis = app($analysis_class); |
57 | 57 | return $analysis instanceof GeoAnalysisInterface ? $analysis : null; |
@@ -25,41 +25,41 @@ |
||
25 | 25 | */ |
26 | 26 | class PlaceMapperService |
27 | 27 | { |
28 | - private ModuleService $module_service; |
|
28 | + private ModuleService $module_service; |
|
29 | 29 | |
30 | - /** |
|
31 | - * Constructor for PlaceMapperService |
|
32 | - * |
|
33 | - * @param ModuleService $module_service |
|
34 | - */ |
|
35 | - public function __construct(ModuleService $module_service) |
|
36 | - { |
|
37 | - $this->module_service = $module_service; |
|
38 | - } |
|
30 | + /** |
|
31 | + * Constructor for PlaceMapperService |
|
32 | + * |
|
33 | + * @param ModuleService $module_service |
|
34 | + */ |
|
35 | + public function __construct(ModuleService $module_service) |
|
36 | + { |
|
37 | + $this->module_service = $module_service; |
|
38 | + } |
|
39 | 39 | |
40 | - /** |
|
41 | - * Get all place mappers available. |
|
42 | - * |
|
43 | - * {@internal The list is generated based on the modules exposing ModulePlaceMapperProviderInterface} |
|
44 | - * |
|
45 | - * @param bool $include_disabled |
|
46 | - * @return Collection<PlaceMapperInterface> |
|
47 | - */ |
|
48 | - public function all(bool $include_disabled = false): Collection |
|
49 | - { |
|
50 | - /** @var Collection<PlaceMapperInterface> $place_mappers */ |
|
51 | - $place_mappers = $this->module_service |
|
52 | - ->findByInterface(ModulePlaceMapperProviderInterface::class, $include_disabled) |
|
53 | - ->flatMap(fn(ModulePlaceMapperProviderInterface $module) => $module->listPlaceMappers()) |
|
54 | - ->map(static function (string $mapper_class): ?PlaceMapperInterface { |
|
55 | - try { |
|
56 | - $mapper = app($mapper_class); |
|
57 | - return $mapper instanceof PlaceMapperInterface ? $mapper : null; |
|
58 | - } catch (BindingResolutionException $ex) { |
|
59 | - return null; |
|
60 | - } |
|
61 | - })->filter(); |
|
40 | + /** |
|
41 | + * Get all place mappers available. |
|
42 | + * |
|
43 | + * {@internal The list is generated based on the modules exposing ModulePlaceMapperProviderInterface} |
|
44 | + * |
|
45 | + * @param bool $include_disabled |
|
46 | + * @return Collection<PlaceMapperInterface> |
|
47 | + */ |
|
48 | + public function all(bool $include_disabled = false): Collection |
|
49 | + { |
|
50 | + /** @var Collection<PlaceMapperInterface> $place_mappers */ |
|
51 | + $place_mappers = $this->module_service |
|
52 | + ->findByInterface(ModulePlaceMapperProviderInterface::class, $include_disabled) |
|
53 | + ->flatMap(fn(ModulePlaceMapperProviderInterface $module) => $module->listPlaceMappers()) |
|
54 | + ->map(static function (string $mapper_class): ?PlaceMapperInterface { |
|
55 | + try { |
|
56 | + $mapper = app($mapper_class); |
|
57 | + return $mapper instanceof PlaceMapperInterface ? $mapper : null; |
|
58 | + } catch (BindingResolutionException $ex) { |
|
59 | + return null; |
|
60 | + } |
|
61 | + })->filter(); |
|
62 | 62 | |
63 | - return $place_mappers; |
|
64 | - } |
|
63 | + return $place_mappers; |
|
64 | + } |
|
65 | 65 | } |
@@ -48,10 +48,10 @@ |
||
48 | 48 | public function all(bool $include_disabled = false): Collection |
49 | 49 | { |
50 | 50 | /** @var Collection<PlaceMapperInterface> $place_mappers */ |
51 | - $place_mappers = $this->module_service |
|
51 | + $place_mappers = $this->module_service |
|
52 | 52 | ->findByInterface(ModulePlaceMapperProviderInterface::class, $include_disabled) |
53 | 53 | ->flatMap(fn(ModulePlaceMapperProviderInterface $module) => $module->listPlaceMappers()) |
54 | - ->map(static function (string $mapper_class): ?PlaceMapperInterface { |
|
54 | + ->map(static function(string $mapper_class): ?PlaceMapperInterface { |
|
55 | 55 | try { |
56 | 56 | $mapper = app($mapper_class); |
57 | 57 | return $mapper instanceof PlaceMapperInterface ? $mapper : null; |
@@ -24,67 +24,67 @@ |
||
24 | 24 | */ |
25 | 25 | trait PlaceMapperTrait |
26 | 26 | { |
27 | - private ?PlaceMapperConfigInterface $config = null; |
|
27 | + private ?PlaceMapperConfigInterface $config = null; |
|
28 | 28 | |
29 | - /** @var array<string, mixed> $data */ |
|
30 | - private array $data = []; |
|
29 | + /** @var array<string, mixed> $data */ |
|
30 | + private array $data = []; |
|
31 | 31 | |
32 | - /** |
|
33 | - * Implementation of PlaceMapperInterface::boot |
|
34 | - * |
|
35 | - * @see \MyArtJaub\Webtrees\Contracts\GeoDispersion\PlaceMapperInterface::boot() |
|
36 | - */ |
|
37 | - public function boot(): void |
|
38 | - { |
|
39 | - } |
|
32 | + /** |
|
33 | + * Implementation of PlaceMapperInterface::boot |
|
34 | + * |
|
35 | + * @see \MyArtJaub\Webtrees\Contracts\GeoDispersion\PlaceMapperInterface::boot() |
|
36 | + */ |
|
37 | + public function boot(): void |
|
38 | + { |
|
39 | + } |
|
40 | 40 | |
41 | - /** |
|
42 | - * Implementation of PlaceMapperInterface::config |
|
43 | - * |
|
44 | - * @see \MyArtJaub\Webtrees\Contracts\GeoDispersion\PlaceMapperInterface::config() |
|
45 | - * |
|
46 | - * @return PlaceMapperConfigInterface |
|
47 | - */ |
|
48 | - public function config(): PlaceMapperConfigInterface |
|
49 | - { |
|
50 | - return $this->config ?? new NullPlaceMapperConfig(); |
|
51 | - } |
|
41 | + /** |
|
42 | + * Implementation of PlaceMapperInterface::config |
|
43 | + * |
|
44 | + * @see \MyArtJaub\Webtrees\Contracts\GeoDispersion\PlaceMapperInterface::config() |
|
45 | + * |
|
46 | + * @return PlaceMapperConfigInterface |
|
47 | + */ |
|
48 | + public function config(): PlaceMapperConfigInterface |
|
49 | + { |
|
50 | + return $this->config ?? new NullPlaceMapperConfig(); |
|
51 | + } |
|
52 | 52 | |
53 | - /** |
|
54 | - * Implementation of PlaceMapperInterface::setConfig |
|
55 | - * |
|
56 | - * @see \MyArtJaub\Webtrees\Contracts\GeoDispersion\PlaceMapperInterface::setConfig() |
|
57 | - * |
|
58 | - * @param PlaceMapperConfigInterface $config |
|
59 | - */ |
|
60 | - public function setConfig(PlaceMapperConfigInterface $config): void |
|
61 | - { |
|
62 | - $this->config = $config; |
|
63 | - } |
|
53 | + /** |
|
54 | + * Implementation of PlaceMapperInterface::setConfig |
|
55 | + * |
|
56 | + * @see \MyArtJaub\Webtrees\Contracts\GeoDispersion\PlaceMapperInterface::setConfig() |
|
57 | + * |
|
58 | + * @param PlaceMapperConfigInterface $config |
|
59 | + */ |
|
60 | + public function setConfig(PlaceMapperConfigInterface $config): void |
|
61 | + { |
|
62 | + $this->config = $config; |
|
63 | + } |
|
64 | 64 | |
65 | - /** |
|
66 | - * Implementation of PlaceMapperInterface::data |
|
67 | - * |
|
68 | - * @see \MyArtJaub\Webtrees\Contracts\GeoDispersion\PlaceMapperInterface::data() |
|
69 | - * |
|
70 | - * @param string $key |
|
71 | - * @return NULL|mixed |
|
72 | - */ |
|
73 | - public function data(string $key) |
|
74 | - { |
|
75 | - return $this->data[$key] ?? null; |
|
76 | - } |
|
65 | + /** |
|
66 | + * Implementation of PlaceMapperInterface::data |
|
67 | + * |
|
68 | + * @see \MyArtJaub\Webtrees\Contracts\GeoDispersion\PlaceMapperInterface::data() |
|
69 | + * |
|
70 | + * @param string $key |
|
71 | + * @return NULL|mixed |
|
72 | + */ |
|
73 | + public function data(string $key) |
|
74 | + { |
|
75 | + return $this->data[$key] ?? null; |
|
76 | + } |
|
77 | 77 | |
78 | - /** |
|
79 | - * Implementation of PlaceMapperInterface::setData |
|
80 | - * |
|
81 | - * @see \MyArtJaub\Webtrees\Contracts\GeoDispersion\PlaceMapperInterface::setData() |
|
82 | - * |
|
83 | - * @param string $key |
|
84 | - * @param mixed|null $data |
|
85 | - */ |
|
86 | - public function setData(string $key, $data): void |
|
87 | - { |
|
88 | - $this->data[$key] = $data; |
|
89 | - } |
|
78 | + /** |
|
79 | + * Implementation of PlaceMapperInterface::setData |
|
80 | + * |
|
81 | + * @see \MyArtJaub\Webtrees\Contracts\GeoDispersion\PlaceMapperInterface::setData() |
|
82 | + * |
|
83 | + * @param string $key |
|
84 | + * @param mixed|null $data |
|
85 | + */ |
|
86 | + public function setData(string $key, $data): void |
|
87 | + { |
|
88 | + $this->data[$key] = $data; |
|
89 | + } |
|
90 | 90 | } |
@@ -21,65 +21,65 @@ |
||
21 | 21 | */ |
22 | 22 | trait TopFilteredPlaceMapperTrait |
23 | 23 | { |
24 | - /** |
|
25 | - * @var Place[] $top_places |
|
26 | - */ |
|
27 | - private array $top_places = []; |
|
24 | + /** |
|
25 | + * @var Place[] $top_places |
|
26 | + */ |
|
27 | + private array $top_places = []; |
|
28 | 28 | |
29 | - /** |
|
30 | - * Get the list of top level places. |
|
31 | - * |
|
32 | - * @return Place[] |
|
33 | - */ |
|
34 | - public function topPlaces(): array |
|
35 | - { |
|
36 | - return $this->top_places; |
|
37 | - } |
|
29 | + /** |
|
30 | + * Get the list of top level places. |
|
31 | + * |
|
32 | + * @return Place[] |
|
33 | + */ |
|
34 | + public function topPlaces(): array |
|
35 | + { |
|
36 | + return $this->top_places; |
|
37 | + } |
|
38 | 38 | |
39 | - /** |
|
40 | - * Set the list of defined top level places. |
|
41 | - * |
|
42 | - * @param Place[] $top_places |
|
43 | - */ |
|
44 | - public function setTopPlaces(array $top_places): void |
|
45 | - { |
|
46 | - $this->top_places = collect($top_places) |
|
47 | - ->filter( |
|
48 | - /** @psalm-suppress MissingClosureParamType */ |
|
49 | - fn($top_places): bool => $top_places instanceof Place |
|
50 | - )->toArray(); |
|
51 | - } |
|
39 | + /** |
|
40 | + * Set the list of defined top level places. |
|
41 | + * |
|
42 | + * @param Place[] $top_places |
|
43 | + */ |
|
44 | + public function setTopPlaces(array $top_places): void |
|
45 | + { |
|
46 | + $this->top_places = collect($top_places) |
|
47 | + ->filter( |
|
48 | + /** @psalm-suppress MissingClosureParamType */ |
|
49 | + fn($top_places): bool => $top_places instanceof Place |
|
50 | + )->toArray(); |
|
51 | + } |
|
52 | 52 | |
53 | - /** |
|
54 | - * Check whether a string ($haystack) ends with another string ($needle) |
|
55 | - * |
|
56 | - * {@internal This is redundant with the function str_ends_with in PHP8} |
|
57 | - * |
|
58 | - * @param string $haystack |
|
59 | - * @param string $needle |
|
60 | - * @return bool |
|
61 | - */ |
|
62 | - private function endsWith(string $haystack, string $needle): bool |
|
63 | - { |
|
64 | - return substr_compare($haystack, $needle, -strlen($needle)) === 0; |
|
65 | - } |
|
53 | + /** |
|
54 | + * Check whether a string ($haystack) ends with another string ($needle) |
|
55 | + * |
|
56 | + * {@internal This is redundant with the function str_ends_with in PHP8} |
|
57 | + * |
|
58 | + * @param string $haystack |
|
59 | + * @param string $needle |
|
60 | + * @return bool |
|
61 | + */ |
|
62 | + private function endsWith(string $haystack, string $needle): bool |
|
63 | + { |
|
64 | + return substr_compare($haystack, $needle, -strlen($needle)) === 0; |
|
65 | + } |
|
66 | 66 | |
67 | - /** |
|
68 | - * Check whether a Place belongs to one of the defined top places. |
|
69 | - * |
|
70 | - * @param Place $place |
|
71 | - * @return bool |
|
72 | - */ |
|
73 | - protected function belongsToTopLevels(Place $place): bool |
|
74 | - { |
|
75 | - foreach ($this->top_places as $top_place) { |
|
76 | - if ( |
|
77 | - $top_place->tree()->id() === $place->tree()->id() && |
|
78 | - $this->endsWith($place->gedcomName(), $top_place->gedcomName()) |
|
79 | - ) { |
|
80 | - return true; |
|
81 | - } |
|
82 | - } |
|
83 | - return false; |
|
84 | - } |
|
67 | + /** |
|
68 | + * Check whether a Place belongs to one of the defined top places. |
|
69 | + * |
|
70 | + * @param Place $place |
|
71 | + * @return bool |
|
72 | + */ |
|
73 | + protected function belongsToTopLevels(Place $place): bool |
|
74 | + { |
|
75 | + foreach ($this->top_places as $top_place) { |
|
76 | + if ( |
|
77 | + $top_place->tree()->id() === $place->tree()->id() && |
|
78 | + $this->endsWith($place->gedcomName(), $top_place->gedcomName()) |
|
79 | + ) { |
|
80 | + return true; |
|
81 | + } |
|
82 | + } |
|
83 | + return false; |
|
84 | + } |
|
85 | 85 | } |