@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | */ |
100 | 100 | public function available(): Collection |
101 | 101 | { |
102 | - return Registry::cache()->array()->remember('maj-available-admintasks', function () { |
|
102 | + return Registry::cache()->array()->remember('maj-available-admintasks', function() { |
|
103 | 103 | return $this->module_service |
104 | 104 | ->findByInterface(ModuleTasksProviderInterface::class) |
105 | 105 | ->flatMap(fn(ModuleTasksProviderInterface $module) => $module->listTasks()); |
@@ -201,14 +201,14 @@ discard block |
||
201 | 201 | $query = DB::table('maj_admintasks') |
202 | 202 | ->select() |
203 | 203 | ->where('majat_status', '=', 'enabled') |
204 | - ->where(function (Builder $query): void { |
|
204 | + ->where(function(Builder $query): void { |
|
205 | 205 | |
206 | 206 | $query->where('majat_running', '=', 0) |
207 | 207 | ->orWhere('majat_last_run', '<=', Carbon::now()->subSeconds(self::TASK_TIME_OUT)); |
208 | 208 | }); |
209 | 209 | |
210 | 210 | if (!$force) { |
211 | - $query->where(function (Builder $query): void { |
|
211 | + $query->where(function(Builder $query): void { |
|
212 | 212 | |
213 | 213 | $query->where('majat_running', '=', 0) |
214 | 214 | ->orWhereRaw('DATE_ADD(majat_last_run, INTERVAL majat_frequency MINUTE) <= NOW()'); |
@@ -256,9 +256,9 @@ discard block |
||
256 | 256 | $task_schedule->setLastResult($task->run($task_schedule)); |
257 | 257 | } catch (Throwable $ex) { |
258 | 258 | if ($first_error) { // Only record the first error, as this could fill the log. |
259 | - Log::addErrorLog(I18N::translate('Error while running task %s:', $task->name()) . ' ' . |
|
260 | - '[' . get_class($ex) . '] ' . $ex->getMessage() . ' ' . $ex->getFile() . ':' |
|
261 | - . $ex->getLine() . PHP_EOL . $ex->getTraceAsString()); |
|
259 | + Log::addErrorLog(I18N::translate('Error while running task %s:', $task->name()).' '. |
|
260 | + '['.get_class($ex).'] '.$ex->getMessage().' '.$ex->getFile().':' |
|
261 | + . $ex->getLine().PHP_EOL.$ex->getTraceAsString()); |
|
262 | 262 | } |
263 | 263 | } |
264 | 264 | |
@@ -279,17 +279,17 @@ discard block |
||
279 | 279 | */ |
280 | 280 | public static function rowMapper(): Closure |
281 | 281 | { |
282 | - return static function (stdClass $row): TaskSchedule { |
|
282 | + return static function(stdClass $row): TaskSchedule { |
|
283 | 283 | |
284 | 284 | return new TaskSchedule( |
285 | - (int) $row->majat_id, |
|
285 | + (int)$row->majat_id, |
|
286 | 286 | $row->majat_task_id, |
287 | 287 | $row->majat_status === 'enabled', |
288 | 288 | Carbon::parse($row->majat_last_run), |
289 | - (bool) $row->majat_last_result, |
|
289 | + (bool)$row->majat_last_result, |
|
290 | 290 | CarbonInterval::minutes($row->majat_frequency), |
291 | - (int) $row->majat_nb_occur, |
|
292 | - (bool) $row->majat_running |
|
291 | + (int)$row->majat_nb_occur, |
|
292 | + (bool)$row->majat_running |
|
293 | 293 | ); |
294 | 294 | }; |
295 | 295 | } |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | public function changesByRecordType(Tree $tree, int $nb_days): Collection |
80 | 80 | { |
81 | 81 | return DB::table('change') |
82 | - ->joinSub($this->allGedcomRecords($tree), 'gedrecords', function (JoinClause $join) use ($tree): void { |
|
82 | + ->joinSub($this->allGedcomRecords($tree), 'gedrecords', function(JoinClause $join) use ($tree): void { |
|
83 | 83 | |
84 | 84 | $join->on('change.xref', '=', 'gedrecords.ged_id') |
85 | 85 | ->where('change.gedcom_id', '=', $tree->id()); |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | new Expression('MAX(log_time) AS lastoccurred') |
116 | 116 | ) |
117 | 117 | ->where('log_type', '=', 'error') |
118 | - ->where(function (Builder $query) use ($tree): void { |
|
118 | + ->where(function(Builder $query) use ($tree): void { |
|
119 | 119 | $query->where('gedcom_id', '=', $tree->id()) |
120 | 120 | ->orWhereNull('gedcom_id'); |
121 | 121 | }) |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | //How to update the database schema for this module |
56 | 56 | private const SCHEMA_TARGET_VERSION = 2; |
57 | 57 | private const SCHEMA_SETTING_NAME = 'MAJ_ADMTASKS_SCHEMA_VERSION'; |
58 | - private const SCHEMA_MIGRATION_PREFIX = __NAMESPACE__ . '\Schema'; |
|
58 | + private const SCHEMA_MIGRATION_PREFIX = __NAMESPACE__.'\Schema'; |
|
59 | 59 | |
60 | 60 | /** |
61 | 61 | * {@inheritDoc} |
@@ -95,12 +95,12 @@ discard block |
||
95 | 95 | */ |
96 | 96 | public function loadRoutes(Map $router): void |
97 | 97 | { |
98 | - $router->attach('', '', static function (Map $router): void { |
|
98 | + $router->attach('', '', static function(Map $router): void { |
|
99 | 99 | |
100 | - $router->attach('', '/module-maj/admintasks', static function (Map $router): void { |
|
100 | + $router->attach('', '/module-maj/admintasks', static function(Map $router): void { |
|
101 | 101 | $router->tokens(['enable' => '[01]']); |
102 | 102 | |
103 | - $router->attach('', '/admin', static function (Map $router): void { |
|
103 | + $router->attach('', '/admin', static function(Map $router): void { |
|
104 | 104 | |
105 | 105 | $router->extras([ |
106 | 106 | 'middleware' => [ |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | ]); |
110 | 110 | $router->get(AdminConfigPage::class, '/config', AdminConfigPage::class); |
111 | 111 | |
112 | - $router->attach('', '/tasks', static function (Map $router): void { |
|
112 | + $router->attach('', '/tasks', static function(Map $router): void { |
|
113 | 113 | |
114 | 114 | $router->get(TasksList::class, '', TasksList::class); |
115 | 115 | $router->get(TaskEditPage::class, '/{task}', TaskEditPage::class); |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | */ |
152 | 152 | public function bodyContent(): string |
153 | 153 | { |
154 | - return view($this->name() . '::snippet', [ 'url' => route(TaskTrigger::class) ]); |
|
154 | + return view($this->name().'::snippet', ['url' => route(TaskTrigger::class)]); |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | /** |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | $interval_lastrun = $task_schedule->lastRunTime()->diffAsCarbonInterval(Carbon::now()); |
137 | 137 | //@phpcs:ignore Generic.Files.LineLength.TooLong |
138 | 138 | $interval = $interval_lastrun->greaterThan($task_schedule->frequency()) ? $interval_lastrun : $task_schedule->frequency(); |
139 | - $nb_days = (int) $interval->ceilDay()->totalDays; |
|
139 | + $nb_days = (int)$interval->ceilDay()->totalDays; |
|
140 | 140 | |
141 | 141 | $view_params_site = [ |
142 | 142 | 'nb_days' => $nb_days, |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | continue; |
156 | 156 | } |
157 | 157 | |
158 | - $webmaster = $this->user_service->find((int) $tree->getPreference('WEBMASTER_USER_ID')); |
|
158 | + $webmaster = $this->user_service->find((int)$tree->getPreference('WEBMASTER_USER_ID')); |
|
159 | 159 | if ($webmaster === null) { |
160 | 160 | continue; |
161 | 161 | } |
@@ -176,9 +176,9 @@ discard block |
||
176 | 176 | new TreeUser($tree), |
177 | 177 | $webmaster, |
178 | 178 | new NoReplyUser(), |
179 | - I18N::translate('Health Check Report') . ' - ' . I18N::translate('Tree %s', $tree->name()), |
|
180 | - view($this->module->name() . '::tasks/healthcheck/email-healthcheck-text', $view_params), |
|
181 | - view($this->module->name() . '::tasks/healthcheck/email-healthcheck-html', $view_params) |
|
179 | + I18N::translate('Health Check Report').' - '.I18N::translate('Tree %s', $tree->name()), |
|
180 | + view($this->module->name().'::tasks/healthcheck/email-healthcheck-text', $view_params), |
|
181 | + view($this->module->name().'::tasks/healthcheck/email-healthcheck-html', $view_params) |
|
182 | 182 | ); |
183 | 183 | } |
184 | 184 | |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | */ |
192 | 192 | public function configView(ServerRequestInterface $request): string |
193 | 193 | { |
194 | - return $this->module === null ? '' : view($this->module->name() . '::tasks/healthcheck/config', [ |
|
194 | + return $this->module === null ? '' : view($this->module->name().'::tasks/healthcheck/config', [ |
|
195 | 195 | 'all_trees' => $this->tree_service->all() |
196 | 196 | ]); |
197 | 197 | } |
@@ -203,11 +203,11 @@ discard block |
||
203 | 203 | public function updateConfig(ServerRequestInterface $request, TaskSchedule $task_schedule): bool |
204 | 204 | { |
205 | 205 | try { |
206 | - $params = (array) $request->getParsedBody(); |
|
206 | + $params = (array)$request->getParsedBody(); |
|
207 | 207 | |
208 | 208 | foreach ($this->tree_service->all() as $tree) { |
209 | 209 | if (Auth::isManager($tree)) { |
210 | - $tree_enabled = (bool) ($params['HEALTHCHECK_ENABLED_' . $tree->id()] ?? false); |
|
210 | + $tree_enabled = (bool)($params['HEALTHCHECK_ENABLED_'.$tree->id()] ?? false); |
|
211 | 211 | $tree->setPreference(self::TREE_PREFERENCE_NAME, $tree_enabled ? '1' : '0'); |
212 | 212 | } |
213 | 213 | } |
@@ -52,7 +52,7 @@ |
||
52 | 52 | // Permissions are configured |
53 | 53 | if (is_numeric($permission_level)) { |
54 | 54 | // Logged in with the correct role? |
55 | - if (Auth::accessLevel($tree, $user) <= (int) $permission_level) { |
|
55 | + if (Auth::accessLevel($tree, $user) <= (int)$permission_level) { |
|
56 | 56 | return $handler->handle($request); |
57 | 57 | } |
58 | 58 |
@@ -57,7 +57,7 @@ |
||
57 | 57 | */ |
58 | 58 | public function name(): string |
59 | 59 | { |
60 | - return $this->module->name() . '-' . |
|
60 | + return $this->module->name().'-'. |
|
61 | 61 | mb_substr(str_replace('collector', '', mb_strtolower((new ReflectionClass($this))->getShortName())), 0, 64); |
62 | 62 | } |
63 | 63 |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | */ |
135 | 135 | public function merge(GeoAnalysisResult $other): self |
136 | 136 | { |
137 | - $this->places->each(function (GeoAnalysisResultItem $item) use ($other): void { |
|
137 | + $this->places->each(function(GeoAnalysisResultItem $item) use ($other): void { |
|
138 | 138 | if ($other->places->has($item->key())) { |
139 | 139 | $item->place()->exclude( |
140 | 140 | $item->place()->isExcluded() |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | } |
144 | 144 | }); |
145 | 145 | |
146 | - $other->places->each(function (GeoAnalysisResultItem $item): void { |
|
146 | + $other->places->each(function(GeoAnalysisResultItem $item): void { |
|
147 | 147 | if (!$this->places->has($item->key())) { |
148 | 148 | $this->addPlace($item->place()); |
149 | 149 | } |
@@ -230,8 +230,8 @@ discard block |
||
230 | 230 | public function sortedKnownPlaces(bool $exclude_other = false): Collection |
231 | 231 | { |
232 | 232 | return $this->knownPlaces($exclude_other)->sortBy([ |
233 | - fn (GeoAnalysisResultItem $a, GeoAnalysisResultItem $b): int => $b->count() <=> $a->count(), |
|
234 | - fn (GeoAnalysisResultItem $a, GeoAnalysisResultItem $b): int => |
|
233 | + fn(GeoAnalysisResultItem $a, GeoAnalysisResultItem $b): int => $b->count() <=> $a->count(), |
|
234 | + fn(GeoAnalysisResultItem $a, GeoAnalysisResultItem $b): int => |
|
235 | 235 | I18N::comparator()($a->place()->place()->gedcomName(), $b->place()->place()->gedcomName()) |
236 | 236 | ]); |
237 | 237 | } |
@@ -105,10 +105,10 @@ |
||
105 | 105 | public function jsonSerialize() |
106 | 106 | { |
107 | 107 | return [ |
108 | - 'default' => (string) $this->defaultColor()->toHex(), |
|
109 | - 'stroke' => (string) $this->strokeColor()->toHex(), |
|
110 | - 'maxvalue' => (string) $this->maxValueColor()->toHex(), |
|
111 | - 'hover' => (string) $this->hoverColor()->toHex(), |
|
108 | + 'default' => (string)$this->defaultColor()->toHex(), |
|
109 | + 'stroke' => (string)$this->strokeColor()->toHex(), |
|
110 | + 'maxvalue' => (string)$this->maxValueColor()->toHex(), |
|
111 | + 'hover' => (string)$this->hoverColor()->toHex(), |
|
112 | 112 | ]; |
113 | 113 | } |
114 | 114 | } |
@@ -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 | } |