Passed
Push — feature/code-analysis ( 60fe63...00c5b4 )
by Jonathan
11:49
created
app/Module/AdminTasks/Tasks/HealthCheckEmailTask.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
         $interval_lastrun = $task_schedule->lastRunTime()->diffAsCarbonInterval(CarbonImmutable::now());
116 116
         $interval_frequency = CarbonInterval::minutes($task_schedule->frequency());
117 117
         $interval = $interval_lastrun->greaterThan($interval_frequency) ? $interval_lastrun : $interval_frequency;
118
-        $nb_days = (int) $interval->ceilDay()->totalDays;
118
+        $nb_days = (int)$interval->ceilDay()->totalDays;
119 119
 
120 120
         $view_params_site = [
121 121
             'nb_days'               =>  $nb_days,
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
                 continue;
135 135
             }
136 136
 
137
-            $webmaster = $this->user_service->find((int) $tree->getPreference('WEBMASTER_USER_ID'));
137
+            $webmaster = $this->user_service->find((int)$tree->getPreference('WEBMASTER_USER_ID'));
138 138
             if ($webmaster === null) {
139 139
                 continue;
140 140
             }
@@ -155,9 +155,9 @@  discard block
 block discarded – undo
155 155
                 new TreeUser($tree),
156 156
                 $webmaster,
157 157
                 new NoReplyUser(),
158
-                I18N::translate('Health Check Report') . ' - ' . I18N::translate('Tree %s', $tree->name()),
159
-                view($this->module->name() . '::tasks/healthcheck/email-healthcheck-text', $view_params),
160
-                view($this->module->name() . '::tasks/healthcheck/email-healthcheck-html', $view_params)
158
+                I18N::translate('Health Check Report').' - '.I18N::translate('Tree %s', $tree->name()),
159
+                view($this->module->name().'::tasks/healthcheck/email-healthcheck-text', $view_params),
160
+                view($this->module->name().'::tasks/healthcheck/email-healthcheck-html', $view_params)
161 161
             );
162 162
         }
163 163
 
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
      */
171 171
     public function configView(ServerRequestInterface $request): string
172 172
     {
173
-        return $this->module === null ? '' : view($this->module->name() . '::tasks/healthcheck/config', [
173
+        return $this->module === null ? '' : view($this->module->name().'::tasks/healthcheck/config', [
174 174
             'all_trees'     =>  $this->tree_service->all()
175 175
         ]);
176 176
     }
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
 
187 187
             foreach ($this->tree_service->all() as $tree) {
188 188
                 if (Auth::isManager($tree)) {
189
-                    $tree_enabled = $validator->boolean('HEALTHCHECK_ENABLED_' . $tree->id(), false);
189
+                    $tree_enabled = $validator->boolean('HEALTHCHECK_ENABLED_'.$tree->id(), false);
190 190
                     $tree->setPreference(self::TREE_PREFERENCE_NAME, $tree_enabled ? '1' : '0');
191 191
                 }
192 192
             }
Please login to merge, or discard this patch.
app/Module/AdminTasks/Http/RequestHandlers/TasksList.php 1 patch
Spacing   +10 added lines, -12 removed lines patch added patch discarded remove patch
@@ -62,13 +62,13 @@  discard block
 block discarded – undo
62 62
         $module = $this->module;
63 63
         $module_name = $this->module->name();
64 64
         return Registry::responseFactory()->response(['data' => $this->taskschedules_service->all(true, true)
65
-            ->map(function (TaskSchedule $schedule) use ($module, $module_name): array {
65
+            ->map(function(TaskSchedule $schedule) use ($module, $module_name): array {
66 66
                 $task = $this->taskschedules_service->findTask($schedule->taskId());
67 67
                 $task_name = $task !== null ? $task->name() : I18N::translate('Task not found');
68 68
                 $last_run_timestamp = Registry::timestampFactory()->make($schedule->lastRunTime()->getTimestamp());
69 69
 
70 70
                 return [
71
-                    'edit' =>   view($module_name . '::admin/tasks-table-options', [
71
+                    'edit' =>   view($module_name.'::admin/tasks-table-options', [
72 72
                         'task_sched_id' => $schedule->id(),
73 73
                         'task_sched_enabled' => $schedule->isEnabled(),
74 74
                         'task_edit_route' => route(TaskEditPage::class, ['task' => $schedule->id()]),
@@ -78,38 +78,36 @@  discard block
 block discarded – undo
78 78
                         ])
79 79
                     ]),
80 80
                     'status'    =>  [
81
-                        'display'   =>  view($module_name . '::components/yes-no-icons', [
81
+                        'display'   =>  view($module_name.'::components/yes-no-icons', [
82 82
                             'yes' => $schedule->isEnabled()
83 83
                         ]),
84 84
                         'raw'       =>  $schedule->isEnabled() ? 1 : 0
85 85
                     ],
86 86
                     'task_name' =>  [
87
-                        'display'   =>  '<bdi>' . e($task_name) . '</bdi>',
87
+                        'display'   =>  '<bdi>'.e($task_name).'</bdi>',
88 88
                         'raw'       =>  $task_name
89 89
                     ],
90 90
                     'last_run'  =>  [
91 91
                         'display'   =>  $last_run_timestamp->timestamp() === 0 ?
92
-                            view('components/datetime', ['timestamp' => $last_run_timestamp]) :
93
-                            view('components/datetime-diff', ['timestamp' => $last_run_timestamp]),
92
+                            view('components/datetime', ['timestamp' => $last_run_timestamp]) : view('components/datetime-diff', ['timestamp' => $last_run_timestamp]),
94 93
                         'raw'       =>  $schedule->lastRunTime()->getTimestamp()
95 94
                     ],
96 95
                     'last_result'   =>  [
97
-                        'display'   => view($module_name . '::components/yes-no-icons', [
96
+                        'display'   => view($module_name.'::components/yes-no-icons', [
98 97
                             'yes' => $schedule->wasLastRunSuccess()
99 98
                         ]),
100 99
                         'raw'       =>  $schedule->wasLastRunSuccess() ? 1 : 0
101 100
                     ],
102 101
                     'frequency' =>
103
-                        '<bdi>' . e(CarbonInterval::minutes($schedule->frequency())->cascade()->forHumans()) . '</bdi>',
102
+                        '<bdi>'.e(CarbonInterval::minutes($schedule->frequency())->cascade()->forHumans()).'</bdi>',
104 103
                     'nb_occurrences'    =>  $schedule->remainingOccurrences() > 0 ?
105
-                        I18N::number($schedule->remainingOccurrences()) :
106
-                        I18N::translate('Unlimited'),
107
-                    'running'   =>  view($module_name . '::components/yes-no-icons', [
104
+                        I18N::number($schedule->remainingOccurrences()) : I18N::translate('Unlimited'),
105
+                    'running'   =>  view($module_name.'::components/yes-no-icons', [
108 106
                         'yes' => $schedule->isRunning(),
109 107
                         'text_yes' => I18N::translate('Running'),
110 108
                         'text_no' => I18N::translate('Not running')
111 109
                     ]),
112
-                    'run'       =>  view($module_name . '::admin/tasks-table-run', [
110
+                    'run'       =>  view($module_name.'::admin/tasks-table-run', [
113 111
                         'task_sched_id' => $schedule->id(),
114 112
                         'run_route' => route(TaskTrigger::class, [
115 113
                             'task'  =>  $schedule->taskId(),
Please login to merge, or discard this patch.
app/Module/AdminTasks/Http/RequestHandlers/TaskTrigger.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@
 block discarded – undo
57 57
         $task_id = Validator::attributes($request)->string('task', '');
58 58
         $token = $this->module->getPreference('MAJ_AT_FORCE_EXEC_TOKEN');
59 59
         $force_token = Validator::queryParams($request)->string('force', '');
60
-        $force = $token !== '' &&  $token === $force_token;
60
+        $force = $token !== '' && $token === $force_token;
61 61
 
62 62
         $task_schedules = $this->taskschedules_service->findTasksToRun($force, $task_id);
63 63
 
Please login to merge, or discard this patch.
app/Module/AdminTasks/Http/RequestHandlers/TaskEditAction.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
                 'success'
84 84
             );
85 85
             //phpcs:ignore Generic.Files.LineLength.TooLong
86
-            Log::addConfigurationLog('Module ' . $this->module->title() . ' : Task Schedule “' . $task_schedule->id() . '” has been updated.');
86
+            Log::addConfigurationLog('Module '.$this->module->title().' : Task Schedule “'.$task_schedule->id().'” has been updated.');
87 87
         }
88 88
 
89 89
         return Registry::responseFactory()->redirect(AdminConfigPage::class);
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
 
140 140
         FlashMessages::addMessage(I18N::translate('An error occured while updating the scheduled task.'), 'danger');
141 141
         //@phpcs:ignore Generic.Files.LineLength.TooLong
142
-        Log::addConfigurationLog('Module ' . $this->module->title() . ' : Task Schedule “' . $task_schedule->id() . '” could not be updated. See error log.');
142
+        Log::addConfigurationLog('Module '.$this->module->title().' : Task Schedule “'.$task_schedule->id().'” could not be updated. See error log.');
143 143
         return false;
144 144
     }
145 145
 
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
                 'danger'
172 172
             );
173 173
             //phpcs:ignore Generic.Files.LineLength.TooLong
174
-            Log::addConfigurationLog('Module ' . $this->module->title() . ' : AdminTask “' . $task->name() . '” specific settings could not be updated. See error log.');
174
+            Log::addConfigurationLog('Module '.$this->module->title().' : AdminTask “'.$task->name().'” specific settings could not be updated. See error log.');
175 175
         }
176 176
 
177 177
         return true;
Please login to merge, or discard this patch.
app/Module/AdminTasks/Http/RequestHandlers/TokenGenerate.php 1 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 Registry::responseFactory()->response(['token' => $token]);
62 62
     }
Please login to merge, or discard this patch.
app/Module/AdminTasks/Http/RequestHandlers/AdminConfigPage.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -63,7 +63,7 @@
 block discarded – undo
63 63
             $this->module->setPreference('MAJ_AT_FORCE_EXEC_TOKEN', $token);
64 64
         }
65 65
 
66
-        return $this->viewResponse($this->module->name() . '::admin/config', [
66
+        return $this->viewResponse($this->module->name().'::admin/config', [
67 67
             'title'             =>  $this->module->title(),
68 68
             'trigger_token'     =>  $token,
69 69
             'trigger_route'     =>  route(TaskTrigger::class, ['task' => '__TASKNAME__', 'force' => '__TOKEN__']),
Please login to merge, or discard this patch.
app/Module/AdminTasks/Http/RequestHandlers/TaskStatusAction.php 1 patch
Spacing   +3 added lines, -4 removed lines patch added patch discarded remove patch
@@ -72,8 +72,7 @@  discard block
 block discarded – undo
72 72
         }
73 73
 
74 74
         Validator::attributes($request)->boolean('enable', false) ?
75
-            $task_schedule->enable() :
76
-            $task_schedule->disable();
75
+            $task_schedule->enable() : $task_schedule->disable();
77 76
 
78 77
         if ($this->taskschedules_service->update($task_schedule) > 0) {
79 78
             FlashMessages::addMessage(
@@ -81,14 +80,14 @@  discard block
 block discarded – undo
81 80
                 'success'
82 81
             );
83 82
             //phpcs:ignore Generic.Files.LineLength.TooLong
84
-            Log::addConfigurationLog('Module ' . $this->module->title() . ' : Task Schedule “' . $task_schedule->id() . '” has been updated.');
83
+            Log::addConfigurationLog('Module '.$this->module->title().' : Task Schedule “'.$task_schedule->id().'” has been updated.');
85 84
         } else {
86 85
             FlashMessages::addMessage(
87 86
                 I18N::translate('An error occured while updating the scheduled task.'),
88 87
                 'danger'
89 88
             );
90 89
             //phpcs:ignore Generic.Files.LineLength.TooLong
91
-            Log::addConfigurationLog('Module ' . $this->module->title() . ' : Task Schedule “' . $task_schedule->id() . '” could not be updated. See error log.');
90
+            Log::addConfigurationLog('Module '.$this->module->title().' : Task Schedule “'.$task_schedule->id().'” could not be updated. See error log.');
92 91
         }
93 92
 
94 93
         return Registry::responseFactory()->redirect(AdminConfigPage::class);
Please login to merge, or discard this patch.
app/Module/AdminTasks/Services/TaskScheduleService.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
     {
102 102
         return Registry::cache()->array()->remember(
103 103
             'maj-available-admintasks',
104
-            function (): Collection {
104
+            function(): Collection {
105 105
                 /** @var Collection<string, string> $tasks */
106 106
                 $tasks = $this->module_service
107 107
                     ->findByInterface(ModuleTasksProviderInterface::class)
@@ -206,13 +206,13 @@  discard block
 block discarded – undo
206 206
         $query = DB::table('maj_admintasks')
207 207
             ->select()
208 208
             ->where('majat_status', '=', 'enabled')
209
-            ->where(function (Builder $query): void {
209
+            ->where(function(Builder $query): void {
210 210
                 $query->where('majat_running', '=', 0)
211 211
                     ->orWhere('majat_last_run', '<=', CarbonImmutable::now('UTC')->subSeconds(self::TASK_TIME_OUT));
212 212
             });
213 213
 
214 214
         if (!$force) {
215
-            $query->where(function (Builder $query): void {
215
+            $query->where(function(Builder $query): void {
216 216
 
217 217
                 $query->where('majat_last_result', '=', 0)
218 218
                     ->orWhereRaw('DATE_ADD(majat_last_run, INTERVAL majat_frequency MINUTE) <= NOW()');
@@ -264,9 +264,9 @@  discard block
 block discarded – undo
264 264
                     $task_schedule->setLastResult($task->run($task_schedule));
265 265
                 } catch (Throwable $ex) {
266 266
                     if ($first_error) { // Only record the first error, as this could fill the log.
267
-                        Log::addErrorLog(I18N::translate('Error while running task %s:', $task->name()) . ' ' .
268
-                            '[' . get_class($ex) . '] ' . $ex->getMessage() . ' ' . $ex->getFile() . ':'
269
-                            . $ex->getLine() . PHP_EOL . $ex->getTraceAsString());
267
+                        Log::addErrorLog(I18N::translate('Error while running task %s:', $task->name()).' '.
268
+                            '['.get_class($ex).'] '.$ex->getMessage().' '.$ex->getFile().':'
269
+                            . $ex->getLine().PHP_EOL.$ex->getTraceAsString());
270 270
                     }
271 271
                 }
272 272
 
@@ -287,16 +287,16 @@  discard block
 block discarded – undo
287 287
      */
288 288
     public static function rowMapper(): Closure
289 289
     {
290
-        return static function (stdClass $row): TaskSchedule {
290
+        return static function(stdClass $row): TaskSchedule {
291 291
             return new TaskSchedule(
292
-                (int) $row->majat_id,
292
+                (int)$row->majat_id,
293 293
                 $row->majat_task_id,
294 294
                 $row->majat_status === 'enabled',
295 295
                 CarbonImmutable::parse($row->majat_last_run, 'UTC'),
296
-                (bool) $row->majat_last_result,
297
-                (int) $row->majat_frequency,
298
-                (int) $row->majat_nb_occur,
299
-                (bool) $row->majat_running
296
+                (bool)$row->majat_last_result,
297
+                (int)$row->majat_frequency,
298
+                (int)$row->majat_nb_occur,
299
+                (bool)$row->majat_running
300 300
             );
301 301
         };
302 302
     }
Please login to merge, or discard this patch.
app/Module/GeoDispersion/Http/RequestHandlers/MapAdapterEditAction.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
         $map_adapter = $this->mapadapter_data_service->find($adapter_id);
77 77
 
78 78
         $map = $this->map_definition_service->find(Validator::parsedBody($request)->string('map_adapter_map', ''));
79
-        $mapping_property   = Validator::parsedBody($request)->string('map_adapter_property_selected', '');
79
+        $mapping_property = Validator::parsedBody($request)->string('map_adapter_property_selected', '');
80 80
 
81 81
         $mapper = null;
82 82
         try {
@@ -101,14 +101,14 @@  discard block
 block discarded – undo
101 101
                 'success'
102 102
             );
103 103
             //phpcs:ignore Generic.Files.LineLength.TooLong
104
-            Log::addConfigurationLog('Module ' . $this->module->title() . ' : Map Adapter “' . $map_adapter->id() . '” has been updated.');
104
+            Log::addConfigurationLog('Module '.$this->module->title().' : Map Adapter “'.$map_adapter->id().'” has been updated.');
105 105
         } catch (Throwable $ex) {
106 106
             FlashMessages::addMessage(
107 107
                 I18N::translate('An error occured while updating the map configuration.'),
108 108
                 'danger'
109 109
             );
110 110
             //phpcs:ignore Generic.Files.LineLength.TooLong
111
-            Log::addErrorLog('Module ' . $this->module->title() . ' : Error when updating Map Adapter “' . $map_adapter->id() . '”: ' . $ex->getMessage());
111
+            Log::addErrorLog('Module '.$this->module->title().' : Error when updating Map Adapter “'.$map_adapter->id().'”: '.$ex->getMessage());
112 112
         }
113 113
 
114 114
         return Registry::responseFactory()->redirect(MapAdapterEditPage::class, [
Please login to merge, or discard this patch.