Passed
Branch feature/2.1-geodispersion-dev (38d49e)
by Jonathan
04:17
created
src/Webtrees/Module/AdminTasks/Contracts/ConfigurableTaskInterface.php 1 patch
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -22,20 +22,20 @@
 block discarded – undo
22 22
 interface ConfigurableTaskInterface
23 23
 {
24 24
     
25
-    /**
26
-     * Returns the HTML code to display the specific task configuration.
27
-     *
28
-     * @param ServerRequestInterface $request
29
-     * @return string HTML code
30
-     */
31
-    public function configView(ServerRequestInterface $request): string;
25
+	/**
26
+	 * Returns the HTML code to display the specific task configuration.
27
+	 *
28
+	 * @param ServerRequestInterface $request
29
+	 * @return string HTML code
30
+	 */
31
+	public function configView(ServerRequestInterface $request): string;
32 32
  
33
-    /**
34
-     * Update the specific configuration of the task.
35
-     *
36
-     * @param ServerRequestInterface $request
37
-     * @param TaskSchedule $task_schedule
38
-     * @return bool Result of the update
39
-     */
40
-    public function updateConfig(ServerRequestInterface $request, TaskSchedule $task_schedule): bool;
33
+	/**
34
+	 * Update the specific configuration of the task.
35
+	 *
36
+	 * @param ServerRequestInterface $request
37
+	 * @param TaskSchedule $task_schedule
38
+	 * @return bool Result of the update
39
+	 */
40
+	public function updateConfig(ServerRequestInterface $request, TaskSchedule $task_schedule): bool;
41 41
 }
Please login to merge, or discard this patch.
src/Webtrees/Module/AdminTasks/Contracts/TaskInterface.php 1 patch
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -19,25 +19,25 @@
 block discarded – undo
19 19
  */
20 20
 interface TaskInterface
21 21
 {
22
-    /**
23
-     * Display name of the task
24
-     *
25
-     * @return string
26
-     */
27
-    public function name(): string;
22
+	/**
23
+	 * Display name of the task
24
+	 *
25
+	 * @return string
26
+	 */
27
+	public function name(): string;
28 28
     
29
-    /**
30
-     * Return the default frequency for the execution of the task, in minutes.
31
-     *
32
-     * @return int Frequency for the execution of the task
33
-     */
34
-    public function defaultFrequency(): int;
29
+	/**
30
+	 * Return the default frequency for the execution of the task, in minutes.
31
+	 *
32
+	 * @return int Frequency for the execution of the task
33
+	 */
34
+	public function defaultFrequency(): int;
35 35
     
36
-    /**
37
-     * Run the task's actions, and return whether the execution has been successful.
38
-     *
39
-     * @param TaskSchedule $task_schedule
40
-     * @return bool Has the execution been a success
41
-     */
42
-    public function run(TaskSchedule $task_schedule): bool;
36
+	/**
37
+	 * Run the task's actions, and return whether the execution has been successful.
38
+	 *
39
+	 * @param TaskSchedule $task_schedule
40
+	 * @return bool Has the execution been a success
41
+	 */
42
+	public function run(TaskSchedule $task_schedule): bool;
43 43
 }
Please login to merge, or discard this patch.
src/Webtrees/Module/AdminTasks/Contracts/ModuleTasksProviderInterface.php 1 patch
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -20,11 +20,11 @@
 block discarded – undo
20 20
 interface ModuleTasksProviderInterface
21 21
 {
22 22
     
23
-    /**
24
-     * List tasks provided by the module as an associative array.
25
-     * They keys are used as task IDs for storage and reference.
26
-     *
27
-     * @return array<string, string> List of tasks
28
-     */
29
-    public function listTasks(): array;
23
+	/**
24
+	 * List tasks provided by the module as an associative array.
25
+	 * They keys are used as task IDs for storage and reference.
26
+	 *
27
+	 * @return array<string, string> List of tasks
28
+	 */
29
+	public function listTasks(): array;
30 30
 }
Please login to merge, or discard this patch.
src/Webtrees/Module/PatronymicLineage/PatronymicLineageModule.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -61,11 +61,11 @@  discard block
 block discarded – undo
61 61
      */
62 62
     public function loadRoutes(Map $router): void
63 63
     {
64
-        $router->attach('', '', static function (Map $router): void {
64
+        $router->attach('', '', static function(Map $router): void {
65 65
 
66
-            $router->attach('', '/module-maj/lineages', static function (Map $router): void {
66
+            $router->attach('', '/module-maj/lineages', static function(Map $router): void {
67 67
 
68
-                $router->attach('', '/Page', static function (Map $router): void {
68
+                $router->attach('', '/Page', static function(Map $router): void {
69 69
 
70 70
                     $router->get(SurnamesList::class, '/{tree}/list{/alpha}', SurnamesList::class);
71 71
                     $router->get(LineagesPage::class, '/{tree}/lineage/{surname}', LineagesPage::class);
@@ -122,6 +122,6 @@  discard block
 block discarded – undo
122 122
      */
123 123
     public function headContent(): string
124 124
     {
125
-        return '<link rel="stylesheet" href="' . e($this->moduleCssUrl()) . '">';
125
+        return '<link rel="stylesheet" href="'.e($this->moduleCssUrl()).'">';
126 126
     }
127 127
 }
Please login to merge, or discard this patch.
Indentation   +95 added lines, -95 removed lines patch added patch discarded remove patch
@@ -34,100 +34,100 @@
 block discarded – undo
34 34
  * Display lineages of people with the same surname.
35 35
  */
36 36
 class PatronymicLineageModule extends IndividualListModule implements
37
-    ModuleMyArtJaubInterface,
38
-    ModuleListInterface,
39
-    ModuleGlobalInterface
37
+	ModuleMyArtJaubInterface,
38
+	ModuleListInterface,
39
+	ModuleGlobalInterface
40 40
 {
41
-    use ModuleMyArtJaubTrait;
42
-    use ModuleListTrait;
43
-    use ModuleGlobalTrait;
44
-
45
-     /**
46
-     * {@inheritDoc}
47
-     * @see \Fisharebest\Webtrees\Module\AbstractModule::title()
48
-     */
49
-    public function title(): string
50
-    {
51
-        return /* I18N: Name of the “Patronymic lineage” module */ I18N::translate('Patronymic Lineages');
52
-    }
53
-
54
-    /**
55
-     * {@inheritDoc}
56
-     * @see \Fisharebest\Webtrees\Module\AbstractModule::description()
57
-     */
58
-    public function description(): string
59
-    {
60
-        //phpcs:ignore Generic.Files.LineLength.TooLong
61
-        return /* I18N: Description of the “Patronymic lineage” module */ I18N::translate('Display lineages of people holding the same surname.');
62
-    }
63
-
64
-    /**
65
-     * {@inheritDoc}
66
-     * @see \MyArtJaub\Webtrees\Module\ModuleMyArtJaubInterface::loadRoutes()
67
-     */
68
-    public function loadRoutes(Map $router): void
69
-    {
70
-        $router->attach('', '', static function (Map $router): void {
71
-
72
-            $router->attach('', '/module-maj/lineages', static function (Map $router): void {
73
-
74
-                $router->attach('', '/Page', static function (Map $router): void {
75
-
76
-                    $router->get(SurnamesList::class, '/{tree}/list{/alpha}', SurnamesList::class);
77
-                    $router->get(LineagesPage::class, '/{tree}/lineage/{surname}', LineagesPage::class);
78
-                });
79
-            });
80
-        });
81
-    }
82
-
83
-    /**
84
-     * {@inheritDoc}
85
-     * @see \Fisharebest\Webtrees\Module\ModuleCustomInterface::customModuleVersion()
86
-     */
87
-    public function customModuleVersion(): string
88
-    {
89
-        return '2.0.11-v.1';
90
-    }
91
-
92
-    /**
93
-     * {@inheritDoc}
94
-     * @see \Fisharebest\Webtrees\Module\ModuleListInterface::listUrl()
95
-     */
96
-    public function listUrl(Tree $tree, array $parameters = []): string
97
-    {
98
-        $surname = $parameters['surname'] ?? '';
99
-
100
-        $xref = app(ServerRequestInterface::class)->getAttribute('xref', '');
101
-        if ($xref !== '' && ($individual = Registry::individualFactory()->make($xref, $tree)) !== null) {
102
-            $surname = $individual->getAllNames()[$individual->getPrimaryName()]['surname'];
103
-        }
104
-
105
-        if ($surname !== '') {
106
-            return route(LineagesPage::class, [
107
-                'tree'      =>  $tree->name(),
108
-                'surname'   =>  $surname
109
-            ] + $parameters);
110
-        }
111
-        return route(SurnamesList::class, [
112
-            'tree'  =>  $tree->name()
113
-        ] + $parameters);
114
-    }
115
-
116
-    /**
117
-     * {@inheritDoc}
118
-     * @see \Fisharebest\Webtrees\Module\ModuleListInterface::listMenuClass()
119
-     */
120
-    public function listMenuClass(): string
121
-    {
122
-        return 'menu-maj-patrolineage';
123
-    }
124
-
125
-    /**
126
-     * {@inheritDoc}
127
-     * @see \Fisharebest\Webtrees\Module\ModuleGlobalInterface::headContent()
128
-     */
129
-    public function headContent(): string
130
-    {
131
-        return '<link rel="stylesheet" href="' . e($this->moduleCssUrl()) . '">';
132
-    }
41
+	use ModuleMyArtJaubTrait;
42
+	use ModuleListTrait;
43
+	use ModuleGlobalTrait;
44
+
45
+	 /**
46
+	  * {@inheritDoc}
47
+	  * @see \Fisharebest\Webtrees\Module\AbstractModule::title()
48
+	  */
49
+	public function title(): string
50
+	{
51
+		return /* I18N: Name of the “Patronymic lineage” module */ I18N::translate('Patronymic Lineages');
52
+	}
53
+
54
+	/**
55
+	 * {@inheritDoc}
56
+	 * @see \Fisharebest\Webtrees\Module\AbstractModule::description()
57
+	 */
58
+	public function description(): string
59
+	{
60
+		//phpcs:ignore Generic.Files.LineLength.TooLong
61
+		return /* I18N: Description of the “Patronymic lineage” module */ I18N::translate('Display lineages of people holding the same surname.');
62
+	}
63
+
64
+	/**
65
+	 * {@inheritDoc}
66
+	 * @see \MyArtJaub\Webtrees\Module\ModuleMyArtJaubInterface::loadRoutes()
67
+	 */
68
+	public function loadRoutes(Map $router): void
69
+	{
70
+		$router->attach('', '', static function (Map $router): void {
71
+
72
+			$router->attach('', '/module-maj/lineages', static function (Map $router): void {
73
+
74
+				$router->attach('', '/Page', static function (Map $router): void {
75
+
76
+					$router->get(SurnamesList::class, '/{tree}/list{/alpha}', SurnamesList::class);
77
+					$router->get(LineagesPage::class, '/{tree}/lineage/{surname}', LineagesPage::class);
78
+				});
79
+			});
80
+		});
81
+	}
82
+
83
+	/**
84
+	 * {@inheritDoc}
85
+	 * @see \Fisharebest\Webtrees\Module\ModuleCustomInterface::customModuleVersion()
86
+	 */
87
+	public function customModuleVersion(): string
88
+	{
89
+		return '2.0.11-v.1';
90
+	}
91
+
92
+	/**
93
+	 * {@inheritDoc}
94
+	 * @see \Fisharebest\Webtrees\Module\ModuleListInterface::listUrl()
95
+	 */
96
+	public function listUrl(Tree $tree, array $parameters = []): string
97
+	{
98
+		$surname = $parameters['surname'] ?? '';
99
+
100
+		$xref = app(ServerRequestInterface::class)->getAttribute('xref', '');
101
+		if ($xref !== '' && ($individual = Registry::individualFactory()->make($xref, $tree)) !== null) {
102
+			$surname = $individual->getAllNames()[$individual->getPrimaryName()]['surname'];
103
+		}
104
+
105
+		if ($surname !== '') {
106
+			return route(LineagesPage::class, [
107
+				'tree'      =>  $tree->name(),
108
+				'surname'   =>  $surname
109
+			] + $parameters);
110
+		}
111
+		return route(SurnamesList::class, [
112
+			'tree'  =>  $tree->name()
113
+		] + $parameters);
114
+	}
115
+
116
+	/**
117
+	 * {@inheritDoc}
118
+	 * @see \Fisharebest\Webtrees\Module\ModuleListInterface::listMenuClass()
119
+	 */
120
+	public function listMenuClass(): string
121
+	{
122
+		return 'menu-maj-patrolineage';
123
+	}
124
+
125
+	/**
126
+	 * {@inheritDoc}
127
+	 * @see \Fisharebest\Webtrees\Module\ModuleGlobalInterface::headContent()
128
+	 */
129
+	public function headContent(): string
130
+	{
131
+		return '<link rel="stylesheet" href="' . e($this->moduleCssUrl()) . '">';
132
+	}
133 133
 }
Please login to merge, or discard this patch.
src/Webtrees/Module/AdminTasks/Model/TaskSchedule.php 1 patch
Indentation   +286 added lines, -286 removed lines patch added patch discarded remove patch
@@ -25,290 +25,290 @@
 block discarded – undo
25 25
 class TaskSchedule
26 26
 {
27 27
 
28
-    /**
29
-     * Task Schedule ID
30
-     * @var int $id
31
-     */
32
-    private $id;
33
-
34
-    /**
35
-     * Task schedule status
36
-     * @var bool $enabled
37
-     */
38
-    private $enabled;
39
-
40
-    /**
41
-     * ID of the task attached to schedule
42
-     * @var string $task_id
43
-     */
44
-    private $task_id;
45
-
46
-    /**
47
-     * Last updated date
48
-     * @var Carbon $last_run
49
-     */
50
-    private $last_run;
51
-
52
-    /**
53
-     * Last run result
54
-     * @var bool $last_result
55
-     */
56
-    private $last_result;
57
-
58
-    /**
59
-     * Task run frequency
60
-     * @var CarbonInterval $frequency
61
-     */
62
-    private $frequency;
63
-
64
-    /**
65
-     * Task remaining runs
66
-     * @var int $nb_occurrences
67
-     */
68
-    private $nb_occurrences;
69
-
70
-    /**
71
-     * Current running status of the task
72
-     * @var bool $is_running
73
-     */
74
-    private $is_running;
75
-
76
-    /**
77
-     * Constructor for TaskSchedule
78
-     *
79
-     * @param int $id Schedule ID
80
-     * @param string $task_id Task ID
81
-     * @param bool $enabled Is the schedule enabled
82
-     * @param Carbon $last_run Last successful run date/time
83
-     * @param bool $last_result Result of the last run
84
-     * @param CarbonInterval $frequency Schedule frequency
85
-     * @param int $nb_occurrences Number of remaining occurrences to be run
86
-     * @param bool $is_running Is the task currently running
87
-     */
88
-    public function __construct(
89
-        int $id,
90
-        string $task_id,
91
-        bool $enabled,
92
-        Carbon $last_run,
93
-        bool $last_result,
94
-        CarbonInterval $frequency,
95
-        int $nb_occurrences,
96
-        bool $is_running
97
-    ) {
98
-        $this->id = $id;
99
-        $this->task_id = $task_id;
100
-        $this->enabled = $enabled;
101
-        $this->last_run = $last_run;
102
-        $this->last_result = $last_result;
103
-        $this->frequency = $frequency;
104
-        $this->nb_occurrences = $nb_occurrences;
105
-        $this->is_running = $is_running;
106
-    }
107
-
108
-    /**
109
-     * Get the schedule ID.
110
-     *
111
-     * @return int
112
-     */
113
-    public function id(): int
114
-    {
115
-        return $this->id;
116
-    }
117
-
118
-    /**
119
-     * Get the task ID.
120
-     *
121
-     * @return string
122
-     */
123
-    public function taskId(): string
124
-    {
125
-        return $this->task_id;
126
-    }
127
-
128
-    /**
129
-     * Returns whether the schedule is enabled
130
-     *
131
-     * @return bool
132
-     */
133
-    public function isEnabled(): bool
134
-    {
135
-        return $this->enabled;
136
-    }
137
-
138
-    /**
139
-     * Enable the schedule
140
-     *
141
-     * @return self
142
-     */
143
-    public function enable(): self
144
-    {
145
-        $this->enabled = true;
146
-        return $this;
147
-    }
148
-
149
-    /**
150
-     * Disable the schedule
151
-     *
152
-     * @return self
153
-     */
154
-    public function disable(): self
155
-    {
156
-        $this->enabled = false;
157
-        return $this;
158
-    }
159
-
160
-    /**
161
-     * Get the frequency of the schedule
162
-     *
163
-     * @return CarbonInterval
164
-     */
165
-    public function frequency(): CarbonInterval
166
-    {
167
-        return $this->frequency;
168
-    }
169
-
170
-    /**
171
-     * Set the frequency of the schedule
172
-     *
173
-     * @param CarbonInterval $frequency
174
-     * @return self
175
-     */
176
-    public function setFrequency(CarbonInterval $frequency): self
177
-    {
178
-        $this->frequency = $frequency;
179
-        return $this;
180
-    }
181
-
182
-    /**
183
-     * Get the date/time of the last successful run.
184
-     *
185
-     * @return Carbon
186
-     */
187
-    public function lastRunTime(): Carbon
188
-    {
189
-        return $this->last_run;
190
-    }
191
-
192
-    /**
193
-     * Set the last successful run date/time
194
-     *
195
-     * @param Carbon $last_run
196
-     * @return self
197
-     */
198
-    public function setLastRunTime(Carbon $last_run): self
199
-    {
200
-        $this->last_run = $last_run;
201
-        return $this;
202
-    }
203
-
204
-    /**
205
-     * Returns whether the last run was successful
206
-     *
207
-     * @return bool
208
-     */
209
-    public function wasLastRunSuccess(): bool
210
-    {
211
-        return $this->last_result;
212
-    }
213
-
214
-    /**
215
-     * Set the last run result
216
-     *
217
-     * @param bool $last_result
218
-     * @return self
219
-     */
220
-    public function setLastResult(bool $last_result): self
221
-    {
222
-        $this->last_result = $last_result;
223
-        return $this;
224
-    }
225
-
226
-    /**
227
-     * Get the number of remaining of occurrences of task runs.
228
-     * Returns 0 if the tasks must be run indefinitely.
229
-     *
230
-     * @return int
231
-     */
232
-    public function remainingOccurences(): int
233
-    {
234
-        return $this->nb_occurrences;
235
-    }
236
-
237
-    /**
238
-     * Decrements the number of remaining occurences by 1.
239
-     * The task will be disabled when the number reaches 0.
240
-     *
241
-     * @return self
242
-     */
243
-    public function decrementRemainingOccurences(): self
244
-    {
245
-        if ($this->nb_occurrences > 0) {
246
-            $this->nb_occurrences--;
247
-            if ($this->nb_occurrences == 0) {
248
-                $this->disable();
249
-            }
250
-        }
251
-        return $this;
252
-    }
253
-
254
-    /**
255
-     * Set the number of remaining occurences of task runs.
256
-     *
257
-     * @param int $nb_occurrences
258
-     * @return self
259
-     */
260
-    public function setRemainingOccurences(int $nb_occurrences): self
261
-    {
262
-        $this->nb_occurrences = $nb_occurrences;
263
-        return $this;
264
-    }
265
-
266
-    /**
267
-     * Returns whether the task is running
268
-     * @return bool
269
-     */
270
-    public function isRunning(): bool
271
-    {
272
-        return $this->is_running;
273
-    }
274
-
275
-    /**
276
-     * Informs the schedule that the task is going to run
277
-     *
278
-     * @return self
279
-     */
280
-    public function startRunning(): self
281
-    {
282
-        $this->is_running = true;
283
-        return $this;
284
-    }
285
-
286
-    /**
287
-     * Informs the schedule that the task has stopped running.
288
-     * @return self
289
-     */
290
-    public function stopRunning(): self
291
-    {
292
-        $this->is_running = false;
293
-        return $this;
294
-    }
295
-
296
-    /**
297
-     * Returns the schedule details as an associate array
298
-     *
299
-     * @return array
300
-     */
301
-    public function toArray(): array
302
-    {
303
-        return [
304
-            'id'            =>  $this->id,
305
-            'task_id'       =>  $this->task_id,
306
-            'enabled'       =>  $this->enabled,
307
-            'last_run'      =>  $this->last_run,
308
-            'last_result'   =>  $this->last_result,
309
-            'frequency'     =>  $this->frequency,
310
-            'nb_occurrences' =>  $this->nb_occurrences,
311
-            'is_running'    =>  $this->is_running
312
-        ];
313
-    }
28
+	/**
29
+	 * Task Schedule ID
30
+	 * @var int $id
31
+	 */
32
+	private $id;
33
+
34
+	/**
35
+	 * Task schedule status
36
+	 * @var bool $enabled
37
+	 */
38
+	private $enabled;
39
+
40
+	/**
41
+	 * ID of the task attached to schedule
42
+	 * @var string $task_id
43
+	 */
44
+	private $task_id;
45
+
46
+	/**
47
+	 * Last updated date
48
+	 * @var Carbon $last_run
49
+	 */
50
+	private $last_run;
51
+
52
+	/**
53
+	 * Last run result
54
+	 * @var bool $last_result
55
+	 */
56
+	private $last_result;
57
+
58
+	/**
59
+	 * Task run frequency
60
+	 * @var CarbonInterval $frequency
61
+	 */
62
+	private $frequency;
63
+
64
+	/**
65
+	 * Task remaining runs
66
+	 * @var int $nb_occurrences
67
+	 */
68
+	private $nb_occurrences;
69
+
70
+	/**
71
+	 * Current running status of the task
72
+	 * @var bool $is_running
73
+	 */
74
+	private $is_running;
75
+
76
+	/**
77
+	 * Constructor for TaskSchedule
78
+	 *
79
+	 * @param int $id Schedule ID
80
+	 * @param string $task_id Task ID
81
+	 * @param bool $enabled Is the schedule enabled
82
+	 * @param Carbon $last_run Last successful run date/time
83
+	 * @param bool $last_result Result of the last run
84
+	 * @param CarbonInterval $frequency Schedule frequency
85
+	 * @param int $nb_occurrences Number of remaining occurrences to be run
86
+	 * @param bool $is_running Is the task currently running
87
+	 */
88
+	public function __construct(
89
+		int $id,
90
+		string $task_id,
91
+		bool $enabled,
92
+		Carbon $last_run,
93
+		bool $last_result,
94
+		CarbonInterval $frequency,
95
+		int $nb_occurrences,
96
+		bool $is_running
97
+	) {
98
+		$this->id = $id;
99
+		$this->task_id = $task_id;
100
+		$this->enabled = $enabled;
101
+		$this->last_run = $last_run;
102
+		$this->last_result = $last_result;
103
+		$this->frequency = $frequency;
104
+		$this->nb_occurrences = $nb_occurrences;
105
+		$this->is_running = $is_running;
106
+	}
107
+
108
+	/**
109
+	 * Get the schedule ID.
110
+	 *
111
+	 * @return int
112
+	 */
113
+	public function id(): int
114
+	{
115
+		return $this->id;
116
+	}
117
+
118
+	/**
119
+	 * Get the task ID.
120
+	 *
121
+	 * @return string
122
+	 */
123
+	public function taskId(): string
124
+	{
125
+		return $this->task_id;
126
+	}
127
+
128
+	/**
129
+	 * Returns whether the schedule is enabled
130
+	 *
131
+	 * @return bool
132
+	 */
133
+	public function isEnabled(): bool
134
+	{
135
+		return $this->enabled;
136
+	}
137
+
138
+	/**
139
+	 * Enable the schedule
140
+	 *
141
+	 * @return self
142
+	 */
143
+	public function enable(): self
144
+	{
145
+		$this->enabled = true;
146
+		return $this;
147
+	}
148
+
149
+	/**
150
+	 * Disable the schedule
151
+	 *
152
+	 * @return self
153
+	 */
154
+	public function disable(): self
155
+	{
156
+		$this->enabled = false;
157
+		return $this;
158
+	}
159
+
160
+	/**
161
+	 * Get the frequency of the schedule
162
+	 *
163
+	 * @return CarbonInterval
164
+	 */
165
+	public function frequency(): CarbonInterval
166
+	{
167
+		return $this->frequency;
168
+	}
169
+
170
+	/**
171
+	 * Set the frequency of the schedule
172
+	 *
173
+	 * @param CarbonInterval $frequency
174
+	 * @return self
175
+	 */
176
+	public function setFrequency(CarbonInterval $frequency): self
177
+	{
178
+		$this->frequency = $frequency;
179
+		return $this;
180
+	}
181
+
182
+	/**
183
+	 * Get the date/time of the last successful run.
184
+	 *
185
+	 * @return Carbon
186
+	 */
187
+	public function lastRunTime(): Carbon
188
+	{
189
+		return $this->last_run;
190
+	}
191
+
192
+	/**
193
+	 * Set the last successful run date/time
194
+	 *
195
+	 * @param Carbon $last_run
196
+	 * @return self
197
+	 */
198
+	public function setLastRunTime(Carbon $last_run): self
199
+	{
200
+		$this->last_run = $last_run;
201
+		return $this;
202
+	}
203
+
204
+	/**
205
+	 * Returns whether the last run was successful
206
+	 *
207
+	 * @return bool
208
+	 */
209
+	public function wasLastRunSuccess(): bool
210
+	{
211
+		return $this->last_result;
212
+	}
213
+
214
+	/**
215
+	 * Set the last run result
216
+	 *
217
+	 * @param bool $last_result
218
+	 * @return self
219
+	 */
220
+	public function setLastResult(bool $last_result): self
221
+	{
222
+		$this->last_result = $last_result;
223
+		return $this;
224
+	}
225
+
226
+	/**
227
+	 * Get the number of remaining of occurrences of task runs.
228
+	 * Returns 0 if the tasks must be run indefinitely.
229
+	 *
230
+	 * @return int
231
+	 */
232
+	public function remainingOccurences(): int
233
+	{
234
+		return $this->nb_occurrences;
235
+	}
236
+
237
+	/**
238
+	 * Decrements the number of remaining occurences by 1.
239
+	 * The task will be disabled when the number reaches 0.
240
+	 *
241
+	 * @return self
242
+	 */
243
+	public function decrementRemainingOccurences(): self
244
+	{
245
+		if ($this->nb_occurrences > 0) {
246
+			$this->nb_occurrences--;
247
+			if ($this->nb_occurrences == 0) {
248
+				$this->disable();
249
+			}
250
+		}
251
+		return $this;
252
+	}
253
+
254
+	/**
255
+	 * Set the number of remaining occurences of task runs.
256
+	 *
257
+	 * @param int $nb_occurrences
258
+	 * @return self
259
+	 */
260
+	public function setRemainingOccurences(int $nb_occurrences): self
261
+	{
262
+		$this->nb_occurrences = $nb_occurrences;
263
+		return $this;
264
+	}
265
+
266
+	/**
267
+	 * Returns whether the task is running
268
+	 * @return bool
269
+	 */
270
+	public function isRunning(): bool
271
+	{
272
+		return $this->is_running;
273
+	}
274
+
275
+	/**
276
+	 * Informs the schedule that the task is going to run
277
+	 *
278
+	 * @return self
279
+	 */
280
+	public function startRunning(): self
281
+	{
282
+		$this->is_running = true;
283
+		return $this;
284
+	}
285
+
286
+	/**
287
+	 * Informs the schedule that the task has stopped running.
288
+	 * @return self
289
+	 */
290
+	public function stopRunning(): self
291
+	{
292
+		$this->is_running = false;
293
+		return $this;
294
+	}
295
+
296
+	/**
297
+	 * Returns the schedule details as an associate array
298
+	 *
299
+	 * @return array
300
+	 */
301
+	public function toArray(): array
302
+	{
303
+		return [
304
+			'id'            =>  $this->id,
305
+			'task_id'       =>  $this->task_id,
306
+			'enabled'       =>  $this->enabled,
307
+			'last_run'      =>  $this->last_run,
308
+			'last_result'   =>  $this->last_result,
309
+			'frequency'     =>  $this->frequency,
310
+			'nb_occurrences' =>  $this->nb_occurrences,
311
+			'is_running'    =>  $this->is_running
312
+		];
313
+	}
314 314
 }
Please login to merge, or discard this patch.
src/Webtrees/Module/AdminTasks/Schema/Migration1.php 2 patches
Indentation   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -25,25 +25,25 @@
 block discarded – undo
25 25
 class Migration1 implements MigrationInterface
26 26
 {
27 27
 
28
-    /**
29
-     * {@inheritDoc}
30
-     * @see \Fisharebest\Webtrees\Schema\MigrationInterface::upgrade()
31
-     */
32
-    public function upgrade(): void
33
-    {
34
-        // Clean up previous admin tasks table if it exists
35
-        DB::schema()->dropIfExists('maj_admintasks');
36
-
37
-        DB::schema()->create('maj_admintasks', static function (Blueprint $table): void {
38
-
39
-            $table->increments('majat_id');
40
-            $table->string('majat_task_id', 32)->unique();
41
-            $table->enum('majat_status', ['enabled', 'disabled'])->default('disabled');
42
-            $table->dateTime('majat_last_run')->default(Carbon::createFromTimestampUTC(0));
43
-            $table->boolean('majat_last_result')->default(true);
44
-            $table->integer('majat_frequency')->default(10080);
45
-            $table->smallInteger('majat_nb_occur')->default(0);
46
-            $table->boolean('majat_running')->default(false);
47
-        });
48
-    }
28
+	/**
29
+	 * {@inheritDoc}
30
+	 * @see \Fisharebest\Webtrees\Schema\MigrationInterface::upgrade()
31
+	 */
32
+	public function upgrade(): void
33
+	{
34
+		// Clean up previous admin tasks table if it exists
35
+		DB::schema()->dropIfExists('maj_admintasks');
36
+
37
+		DB::schema()->create('maj_admintasks', static function (Blueprint $table): void {
38
+
39
+			$table->increments('majat_id');
40
+			$table->string('majat_task_id', 32)->unique();
41
+			$table->enum('majat_status', ['enabled', 'disabled'])->default('disabled');
42
+			$table->dateTime('majat_last_run')->default(Carbon::createFromTimestampUTC(0));
43
+			$table->boolean('majat_last_result')->default(true);
44
+			$table->integer('majat_frequency')->default(10080);
45
+			$table->smallInteger('majat_nb_occur')->default(0);
46
+			$table->boolean('majat_running')->default(false);
47
+		});
48
+	}
49 49
 }
Please login to merge, or discard this patch.
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.
src/Webtrees/Module/AdminTasks/Services/HealthCheckService.php 2 patches
Indentation   +93 added lines, -93 removed lines patch added patch discarded remove patch
@@ -27,101 +27,101 @@
 block discarded – undo
27 27
  */
28 28
 class HealthCheckService
29 29
 {
30
-    /**
31
-     * Returns a query collating all gedcom records, for use in other queries
32
-     *
33
-     * @param Tree $tree
34
-     * @return Builder
35
-     */
36
-    private function allGedcomRecords(Tree $tree): Builder
37
-    {
38
-        return DB::table('individuals')
39
-            ->select(DB::raw("'indi' AS ged_type"), 'i_id AS ged_id')->where('i_file', '=', $tree->id())
40
-            ->unionAll(DB::table('families')
41
-                ->select(DB::raw("'fam' AS ged_type"), 'f_id AS ged_id')->where('f_file', '=', $tree->id()))
42
-            ->unionAll(DB::table('sources')
43
-                ->select(DB::raw("'sour' AS ged_type"), 's_id AS ged_id')->where('s_file', '=', $tree->id()))
44
-            ->unionAll(DB::table('media')
45
-                ->select(DB::raw("'media' AS ged_type"), 'm_id AS ged_id')->where('m_file', '=', $tree->id()))
46
-            ->unionAll(DB::table('other')
47
-                ->select(DB::raw('LOWER(o_type) AS ged_type'), 'o_id AS ged_id')->where('o_file', '=', $tree->id()));
48
-    }
30
+	/**
31
+	 * Returns a query collating all gedcom records, for use in other queries
32
+	 *
33
+	 * @param Tree $tree
34
+	 * @return Builder
35
+	 */
36
+	private function allGedcomRecords(Tree $tree): Builder
37
+	{
38
+		return DB::table('individuals')
39
+			->select(DB::raw("'indi' AS ged_type"), 'i_id AS ged_id')->where('i_file', '=', $tree->id())
40
+			->unionAll(DB::table('families')
41
+				->select(DB::raw("'fam' AS ged_type"), 'f_id AS ged_id')->where('f_file', '=', $tree->id()))
42
+			->unionAll(DB::table('sources')
43
+				->select(DB::raw("'sour' AS ged_type"), 's_id AS ged_id')->where('s_file', '=', $tree->id()))
44
+			->unionAll(DB::table('media')
45
+				->select(DB::raw("'media' AS ged_type"), 'm_id AS ged_id')->where('m_file', '=', $tree->id()))
46
+			->unionAll(DB::table('other')
47
+				->select(DB::raw('LOWER(o_type) AS ged_type'), 'o_id AS ged_id')->where('o_file', '=', $tree->id()));
48
+	}
49 49
 
50
-    /**
51
-     * Returns the count of gedcom records by type in a Tree, as a keyed Collection.
52
-     *
53
-     * Collection output:
54
-     *      - Key : gedcom record type
55
-     *      - Value: count of records
56
-     *
57
-     * @param Tree $tree
58
-     * @return Collection
59
-     */
60
-    public function countByRecordType(Tree $tree): Collection
61
-    {
62
-        return DB::query()
63
-            ->fromSub($this->allGedcomRecords($tree), 'gedrecords')
64
-            ->select('ged_type', new Expression('COUNT(ged_id) AS total'))
65
-            ->groupBy('ged_type')
66
-            ->pluck('total', 'ged_type');
67
-    }
50
+	/**
51
+	 * Returns the count of gedcom records by type in a Tree, as a keyed Collection.
52
+	 *
53
+	 * Collection output:
54
+	 *      - Key : gedcom record type
55
+	 *      - Value: count of records
56
+	 *
57
+	 * @param Tree $tree
58
+	 * @return Collection
59
+	 */
60
+	public function countByRecordType(Tree $tree): Collection
61
+	{
62
+		return DB::query()
63
+			->fromSub($this->allGedcomRecords($tree), 'gedrecords')
64
+			->select('ged_type', new Expression('COUNT(ged_id) AS total'))
65
+			->groupBy('ged_type')
66
+			->pluck('total', 'ged_type');
67
+	}
68 68
 
69
-    /**
70
-     * Returns the count of gedcom records changes by type in a Tree across a number of days, as a keyed Collection.
71
-     *
72
-     * Collection output:
73
-     *      - Key : gedcom record type
74
-     *      - Value: count of changes
75
-     *
76
-     * @param Tree $tree
77
-     * @return Collection
78
-     */
79
-    public function changesByRecordType(Tree $tree, int $nb_days): Collection
80
-    {
81
-        return DB::table('change')
82
-            ->joinSub($this->allGedcomRecords($tree), 'gedrecords', function (JoinClause $join) use ($tree): void {
69
+	/**
70
+	 * Returns the count of gedcom records changes by type in a Tree across a number of days, as a keyed Collection.
71
+	 *
72
+	 * Collection output:
73
+	 *      - Key : gedcom record type
74
+	 *      - Value: count of changes
75
+	 *
76
+	 * @param Tree $tree
77
+	 * @return Collection
78
+	 */
79
+	public function changesByRecordType(Tree $tree, int $nb_days): Collection
80
+	{
81
+		return DB::table('change')
82
+			->joinSub($this->allGedcomRecords($tree), 'gedrecords', function (JoinClause $join) use ($tree): void {
83 83
 
84
-                $join->on('change.xref', '=', 'gedrecords.ged_id')
85
-                    ->where('change.gedcom_id', '=', $tree->id());
86
-            })
87
-            ->select('ged_type AS type', new Expression('COUNT(change_id) AS count'))
88
-            ->where('change.status', '', 'accepted')
89
-            ->where('change.change_time', '>=', Carbon::now()->subDays($nb_days))
90
-            ->groupBy('ged_type')
91
-            ->pluck('total', 'ged_type');
92
-    }
84
+				$join->on('change.xref', '=', 'gedrecords.ged_id')
85
+					->where('change.gedcom_id', '=', $tree->id());
86
+			})
87
+			->select('ged_type AS type', new Expression('COUNT(change_id) AS count'))
88
+			->where('change.status', '', 'accepted')
89
+			->where('change.change_time', '>=', Carbon::now()->subDays($nb_days))
90
+			->groupBy('ged_type')
91
+			->pluck('total', 'ged_type');
92
+	}
93 93
 
94
-    /**
95
-     * Return the error logs associated with a tree across a number of days, grouped by error message, as a Collection.
96
-     *
97
-     * Collection output:
98
-     *      - Value: stdClass object
99
-     *          - log message:  Error log message
100
-     *          - type:         'site' if no associated Tree, the Tree ID otherwise
101
-     *          - nblogs:       The number of occurence of the same error message
102
-     *          - lastoccurred: Date/time of the last occurence of the error message
103
-     *
104
-     * @param Tree $tree
105
-     * @param int $nb_days
106
-     * @return Collection
107
-     */
108
-    public function errorLogs(Tree $tree, int $nb_days): Collection
109
-    {
110
-        return DB::table('log')
111
-            ->select(
112
-                'log_message',
113
-                new Expression("IFNULL(gedcom_id, 'site') as type"),
114
-                new Expression('COUNT(log_id) AS nblogs'),
115
-                new Expression('MAX(log_time) AS lastoccurred')
116
-            )
117
-            ->where('log_type', '=', 'error')
118
-            ->where(function (Builder $query) use ($tree): void {
119
-                $query->where('gedcom_id', '=', $tree->id())
120
-                    ->orWhereNull('gedcom_id');
121
-            })
122
-            ->where('log_time', '>=', Carbon::now()->subDays($nb_days))
123
-            ->groupBy('log_message', 'gedcom_id')
124
-            ->orderByDesc('lastoccurred')
125
-            ->get();
126
-    }
94
+	/**
95
+	 * Return the error logs associated with a tree across a number of days, grouped by error message, as a Collection.
96
+	 *
97
+	 * Collection output:
98
+	 *      - Value: stdClass object
99
+	 *          - log message:  Error log message
100
+	 *          - type:         'site' if no associated Tree, the Tree ID otherwise
101
+	 *          - nblogs:       The number of occurence of the same error message
102
+	 *          - lastoccurred: Date/time of the last occurence of the error message
103
+	 *
104
+	 * @param Tree $tree
105
+	 * @param int $nb_days
106
+	 * @return Collection
107
+	 */
108
+	public function errorLogs(Tree $tree, int $nb_days): Collection
109
+	{
110
+		return DB::table('log')
111
+			->select(
112
+				'log_message',
113
+				new Expression("IFNULL(gedcom_id, 'site') as type"),
114
+				new Expression('COUNT(log_id) AS nblogs'),
115
+				new Expression('MAX(log_time) AS lastoccurred')
116
+			)
117
+			->where('log_type', '=', 'error')
118
+			->where(function (Builder $query) use ($tree): void {
119
+				$query->where('gedcom_id', '=', $tree->id())
120
+					->orWhereNull('gedcom_id');
121
+			})
122
+			->where('log_time', '>=', Carbon::now()->subDays($nb_days))
123
+			->groupBy('log_message', 'gedcom_id')
124
+			->orderByDesc('lastoccurred')
125
+			->get();
126
+	}
127 127
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
             })
Please login to merge, or discard this patch.
src/Webtrees/Module/Sosa/Schema/Migration1.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -22,12 +22,12 @@
 block discarded – undo
22 22
 class Migration1 implements MigrationInterface
23 23
 {
24 24
     
25
-    /**
26
-     * {@inheritDoc}
27
-     * @see \Fisharebest\Webtrees\Schema\MigrationInterface::upgrade()
28
-     */
29
-    public function upgrade(): void
30
-    {
31
-        // These migrations have been merged into migration 2.
32
-    }
25
+	/**
26
+	 * {@inheritDoc}
27
+	 * @see \Fisharebest\Webtrees\Schema\MigrationInterface::upgrade()
28
+	 */
29
+	public function upgrade(): void
30
+	{
31
+		// These migrations have been merged into migration 2.
32
+	}
33 33
 }
Please login to merge, or discard this patch.
src/Webtrees/Module/Sosa/Http/RequestHandlers/SosaComputeModal.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -60,7 +60,7 @@
 block discarded – undo
60 60
         $tree = $request->getAttribute('tree');
61 61
         assert($tree instanceof Tree);
62 62
 
63
-        return response(view($this->module->name() . '::modals/sosa-compute', [
63
+        return response(view($this->module->name().'::modals/sosa-compute', [
64 64
             'tree'          => $tree,
65 65
             'xref'          =>  $request->getAttribute('xref')
66 66
         ]));
Please login to merge, or discard this patch.
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -28,40 +28,40 @@
 block discarded – undo
28 28
  */
29 29
 class SosaComputeModal implements RequestHandlerInterface
30 30
 {
31
-    /**
32
-     * @var SosaModule|null $module
33
-     */
34
-    private $module;
31
+	/**
32
+	 * @var SosaModule|null $module
33
+	 */
34
+	private $module;
35 35
 
36
-    /**
37
-     * Constructor for SosaComputeModal Request Handler
38
-     *
39
-     * @param ModuleService $module_service
40
-     */
41
-    public function __construct(ModuleService $module_service)
42
-    {
43
-        $this->module = $module_service->findByInterface(SosaModule::class)->first();
44
-    }
36
+	/**
37
+	 * Constructor for SosaComputeModal Request Handler
38
+	 *
39
+	 * @param ModuleService $module_service
40
+	 */
41
+	public function __construct(ModuleService $module_service)
42
+	{
43
+		$this->module = $module_service->findByInterface(SosaModule::class)->first();
44
+	}
45 45
 
46
-    /**
47
-     * {@inheritDoc}
48
-     * @see \Psr\Http\Server\RequestHandlerInterface::handle()
49
-     */
50
-    public function handle(ServerRequestInterface $request): ResponseInterface
51
-    {
52
-        if ($this->module === null) {
53
-            return response(view('modals/error', [
54
-                'title' => I18N::translate('Error'),
55
-                'error' => I18N::translate('The attached module could not be found.')
56
-            ]));
57
-        }
46
+	/**
47
+	 * {@inheritDoc}
48
+	 * @see \Psr\Http\Server\RequestHandlerInterface::handle()
49
+	 */
50
+	public function handle(ServerRequestInterface $request): ResponseInterface
51
+	{
52
+		if ($this->module === null) {
53
+			return response(view('modals/error', [
54
+				'title' => I18N::translate('Error'),
55
+				'error' => I18N::translate('The attached module could not be found.')
56
+			]));
57
+		}
58 58
 
59
-        $tree = $request->getAttribute('tree');
60
-        assert($tree instanceof Tree);
59
+		$tree = $request->getAttribute('tree');
60
+		assert($tree instanceof Tree);
61 61
 
62
-        return response(view($this->module->name() . '::modals/sosa-compute', [
63
-            'tree'          => $tree,
64
-            'xref'          =>  $request->getAttribute('xref')
65
-        ]));
66
-    }
62
+		return response(view($this->module->name() . '::modals/sosa-compute', [
63
+			'tree'          => $tree,
64
+			'xref'          =>  $request->getAttribute('xref')
65
+		]));
66
+	}
67 67
 }
Please login to merge, or discard this patch.