Passed
Push — main ( 00c5b4...fe37d7 )
by Jonathan
03:49
created
app/Module/IsSourced/IsSourcedModule.php 1 patch
Indentation   +90 added lines, -90 removed lines patch added patch discarded remove patch
@@ -33,105 +33,105 @@
 block discarded – undo
33 33
  * IsSourced Module
34 34
  */
35 35
 class IsSourcedModule extends AbstractModule implements
36
-    ModuleMyArtJaubInterface,
37
-    ModuleGlobalInterface,
38
-    ModuleSidebarInterface,
39
-    ModuleHookSubscriberInterface
36
+	ModuleMyArtJaubInterface,
37
+	ModuleGlobalInterface,
38
+	ModuleSidebarInterface,
39
+	ModuleHookSubscriberInterface
40 40
 {
41
-    use ModuleMyArtJaubTrait;
42
-    use ModuleGlobalTrait;
43
-    use ModuleSidebarTrait;
41
+	use ModuleMyArtJaubTrait;
42
+	use ModuleGlobalTrait;
43
+	use ModuleSidebarTrait;
44 44
 
45
-    /**
46
-     * {@inheritDoc}
47
-     * @see \Fisharebest\Webtrees\Module\AbstractModule::title()
48
-     */
49
-    public function title(): string
50
-    {
51
-        return I18N::translate('Sourced events');
52
-    }
45
+	/**
46
+	 * {@inheritDoc}
47
+	 * @see \Fisharebest\Webtrees\Module\AbstractModule::title()
48
+	 */
49
+	public function title(): string
50
+	{
51
+		return I18N::translate('Sourced events');
52
+	}
53 53
 
54
-    /**
55
-     * {@inheritDoc}
56
-     * @see \Fisharebest\Webtrees\Module\AbstractModule::description()
57
-     */
58
-    public function description(): string
59
-    {
60
-        return I18N::translate('Indicate if events related to an record are sourced.');
61
-    }
54
+	/**
55
+	 * {@inheritDoc}
56
+	 * @see \Fisharebest\Webtrees\Module\AbstractModule::description()
57
+	 */
58
+	public function description(): string
59
+	{
60
+		return I18N::translate('Indicate if events related to an record are sourced.');
61
+	}
62 62
 
63
-    /**
64
-     * {@inheritDoc}
65
-     * @see \Fisharebest\Webtrees\Module\ModuleCustomInterface::customModuleVersion()
66
-     */
67
-    public function customModuleVersion(): string
68
-    {
69
-        return '2.1.1-v.1';
70
-    }
63
+	/**
64
+	 * {@inheritDoc}
65
+	 * @see \Fisharebest\Webtrees\Module\ModuleCustomInterface::customModuleVersion()
66
+	 */
67
+	public function customModuleVersion(): string
68
+	{
69
+		return '2.1.1-v.1';
70
+	}
71 71
 
72
-    /**
73
-     * {@inheritDoc}
74
-     * @see \Fisharebest\Webtrees\Module\ModuleGlobalInterface::headContent()
75
-     */
76
-    public function headContent(): string
77
-    {
78
-        return '<link rel="stylesheet" href="' . e($this->moduleCssUrl()) . '">';
79
-    }
72
+	/**
73
+	 * {@inheritDoc}
74
+	 * @see \Fisharebest\Webtrees\Module\ModuleGlobalInterface::headContent()
75
+	 */
76
+	public function headContent(): string
77
+	{
78
+		return '<link rel="stylesheet" href="' . e($this->moduleCssUrl()) . '">';
79
+	}
80 80
 
81
-    /**
82
-     * {@inheritDoc}
83
-     * @see \Fisharebest\Webtrees\Module\ModuleGlobalInterface::bodyContent()
84
-     */
85
-    public function bodyContent(): string
86
-    {
87
-        return '<script src="' . $this->assetUrl('js/issourced.min.js') . '"></script>';
88
-    }
81
+	/**
82
+	 * {@inheritDoc}
83
+	 * @see \Fisharebest\Webtrees\Module\ModuleGlobalInterface::bodyContent()
84
+	 */
85
+	public function bodyContent(): string
86
+	{
87
+		return '<script src="' . $this->assetUrl('js/issourced.min.js') . '"></script>';
88
+	}
89 89
 
90
-    /**
91
-     * {@inheritDoc}
92
-     * @see \Fisharebest\Webtrees\Module\ModuleSidebarInterface::hasSidebarContent()
93
-     */
94
-    public function hasSidebarContent(Individual $individual): bool
95
-    {
96
-        return true;
97
-    }
90
+	/**
91
+	 * {@inheritDoc}
92
+	 * @see \Fisharebest\Webtrees\Module\ModuleSidebarInterface::hasSidebarContent()
93
+	 */
94
+	public function hasSidebarContent(Individual $individual): bool
95
+	{
96
+		return true;
97
+	}
98 98
 
99
-    /**
100
-     * {@inheritDoc}
101
-     * @see \Fisharebest\Webtrees\Module\ModuleSidebarInterface::getSidebarContent()
102
-     */
103
-    public function getSidebarContent(Individual $individual): string
104
-    {
105
-        /** @var SourceStatusService $source_status_service */
106
-        $source_status_service = app(SourceStatusService::class);
99
+	/**
100
+	 * {@inheritDoc}
101
+	 * @see \Fisharebest\Webtrees\Module\ModuleSidebarInterface::getSidebarContent()
102
+	 */
103
+	public function getSidebarContent(Individual $individual): string
104
+	{
105
+		/** @var SourceStatusService $source_status_service */
106
+		$source_status_service = app(SourceStatusService::class);
107 107
 
108
-        $spouse_families_status = $individual->spouseFamilies()->map(
109
-            function (Family $sfamily) use ($source_status_service): array {
110
-                return [ $sfamily, $source_status_service->sourceStatusForMarriage($sfamily)];
111
-            }
112
-        )->filter(function (array $item): bool {
113
-            return $item[1]->isSet();
114
-        });
108
+		$spouse_families_status = $individual->spouseFamilies()->map(
109
+			function (Family $sfamily) use ($source_status_service): array {
110
+				return [ $sfamily, $source_status_service->sourceStatusForMarriage($sfamily)];
111
+			}
112
+		)->filter(function (array $item): bool {
113
+			return $item[1]->isSet();
114
+		});
115 115
 
116
-        return view($this->name() . '::sidebar/content', [
117
-            'module_name'               => $this->name(),
118
-            'individual'                =>  $individual,
119
-            'source_status_individual'  =>  $source_status_service->sourceStatusForRecord($individual),
120
-            'source_status_birth'       =>  $source_status_service->sourceStatusForBirth($individual),
121
-            'source_status_marriages'   =>  $spouse_families_status,
122
-            'source_status_death'       =>  $source_status_service->sourceStatusForDeath($individual)
123
-        ]);
124
-    }
116
+		return view($this->name() . '::sidebar/content', [
117
+			'module_name'               => $this->name(),
118
+			'individual'                =>  $individual,
119
+			'source_status_individual'  =>  $source_status_service->sourceStatusForRecord($individual),
120
+			'source_status_birth'       =>  $source_status_service->sourceStatusForBirth($individual),
121
+			'source_status_marriages'   =>  $spouse_families_status,
122
+			'source_status_death'       =>  $source_status_service->sourceStatusForDeath($individual)
123
+		]);
124
+	}
125 125
 
126
-    /**
127
-     * {@inheritDoc}
128
-     * @see \MyArtJaub\Webtrees\Contracts\Hooks\ModuleHookSubscriberInterface::listSubscribedHooks()
129
-     */
130
-    public function listSubscribedHooks(): array
131
-    {
132
-        return [
133
-            app()->makeWith(IsSourcedStatusHook::class, [ 'module' => $this ]),
134
-            app()->makeWith(IsSourcedStatusColumnsHook::class, [ 'module' => $this ])
135
-        ];
136
-    }
126
+	/**
127
+	 * {@inheritDoc}
128
+	 * @see \MyArtJaub\Webtrees\Contracts\Hooks\ModuleHookSubscriberInterface::listSubscribedHooks()
129
+	 */
130
+	public function listSubscribedHooks(): array
131
+	{
132
+		return [
133
+			app()->makeWith(IsSourcedStatusHook::class, [ 'module' => $this ]),
134
+			app()->makeWith(IsSourcedStatusColumnsHook::class, [ 'module' => $this ])
135
+		];
136
+	}
137 137
 }
Please login to merge, or discard this patch.
app/Module/IsSourced/Data/FactSourceStatus.php 1 patch
Indentation   +229 added lines, -229 removed lines patch added patch discarded remove patch
@@ -22,233 +22,233 @@
 block discarded – undo
22 22
  */
23 23
 class FactSourceStatus extends SourceStatus
24 24
 {
25
-    /**
26
-     * @var boolean $has_date
27
-     */
28
-    private $has_date = false;
29
-
30
-    /**
31
-     * @var boolean $has_precise_date
32
-     */
33
-    private $has_precise_date = false;
34
-
35
-    /**
36
-     * @var boolean $has_source_date
37
-     */
38
-    private $has_source_date = false;
39
-
40
-    /**
41
-     * @var boolean $source_date_match
42
-     */
43
-    private $source_date_match = false;
44
-
45
-    /**
46
-     * Return whether the fact is dated.
47
-     *
48
-     * @return bool
49
-     */
50
-    public function factHasDate(): bool
51
-    {
52
-        return $this->has_date;
53
-    }
54
-
55
-    /**
56
-     * Set whether the fact is dated.
57
-     *
58
-     * @param bool $has_date
59
-     * @return $this
60
-     */
61
-    public function setFactHasDate(bool $has_date): self
62
-    {
63
-        $this->has_date = $has_date;
64
-        return $this;
65
-    }
66
-
67
-    /**
68
-     * Combinate whether the fact is dated with the previous status.
69
-     *
70
-     * @param bool $has_date
71
-     * @return $this
72
-     */
73
-    public function addFactHasDate(bool $has_date): self
74
-    {
75
-        $this->has_date = $this->has_date || $has_date;
76
-        return $this;
77
-    }
78
-
79
-    /**
80
-     * Return whether the fact is dated with a precise day.
81
-     * Any date modifier will be considered as not precise.
82
-     * A month or year will be considered as not precise.
83
-     *
84
-     * @return bool
85
-     */
86
-    public function factHasPreciseDate(): bool
87
-    {
88
-        return $this->has_date && $this->has_precise_date;
89
-    }
90
-
91
-    /**
92
-     * Set whather the fact is dated with a precise day.
93
-     *
94
-     * @param bool $has_precise_date
95
-     * @return $this
96
-     */
97
-    public function setFactHasPreciseDate(bool $has_precise_date): self
98
-    {
99
-        $this->has_precise_date = $has_precise_date;
100
-        return $this;
101
-    }
102
-
103
-    /**
104
-     * Combine whether the fact is dated with a precise day.
105
-     *
106
-     * @param bool $has_precise_date
107
-     * @return $this
108
-     */
109
-    public function addFactHasPreciseDate(bool $has_precise_date): self
110
-    {
111
-        $this->has_precise_date = $this->has_precise_date || $has_precise_date;
112
-        return $this;
113
-    }
114
-
115
-    /**
116
-     * Return whether the source citation is dated.
117
-     *
118
-     * @return bool
119
-     */
120
-    public function sourceHasDate(): bool
121
-    {
122
-        return $this->has_source_date;
123
-    }
124
-
125
-    /**
126
-     * Set whether the source citation is dated.
127
-     *
128
-     * @param bool $has_source_date
129
-     * @return $this
130
-     */
131
-    public function setSourceHasDate(bool $has_source_date): self
132
-    {
133
-        $this->has_source_date = $has_source_date;
134
-        return $this;
135
-    }
136
-
137
-    /**
138
-     * Combine whether the source citation is dated with the previous status.
139
-     *
140
-     * @param bool $has_source_date
141
-     * @return $this
142
-     */
143
-    public function addSourceHasDate(bool $has_source_date): self
144
-    {
145
-        $this->has_source_date = $this->has_source_date || $has_source_date;
146
-        return $this;
147
-    }
148
-
149
-    /**
150
-     * Return whether the source citation date is close to the fact date.
151
-     *
152
-     * @return bool
153
-     */
154
-    public function sourceMatchesFactDate(): bool
155
-    {
156
-        return $this->has_precise_date && $this->has_source_date && $this->source_date_match;
157
-    }
158
-
159
-    /**
160
-     * Set whether the source citation date is close to the fact date.
161
-     *
162
-     * @param bool $source_date_match
163
-     * @return $this
164
-     */
165
-    public function setSourceMatchesFactDate(bool $source_date_match): self
166
-    {
167
-        $this->source_date_match = $source_date_match;
168
-        return $this;
169
-    }
170
-
171
-    /**
172
-     * Combine whether the source citation date is close to the fact date with the previous status.
173
-     *
174
-     * @param bool $source_date_match
175
-     * @return $this
176
-     */
177
-    public function addSourceMatchesFactDate(bool $source_date_match): self
178
-    {
179
-        $this->source_date_match = $this->source_date_match || $source_date_match;
180
-        return $this;
181
-    }
182
-
183
-    /**
184
-     * {@inheritDoc}
185
-     * @see \MyArtJaub\Webtrees\Module\IsSourced\Data\SourceStatus::isFullySourced()
186
-     */
187
-    public function isFullySourced(): bool
188
-    {
189
-        return parent::isFullySourced() && $this->sourceMatchesFactDate();
190
-    }
191
-
192
-    /**
193
-     * {@inheritDoc}
194
-     * @see \MyArtJaub\Webtrees\Module\IsSourced\Data\SourceStatus::label()
195
-     */
196
-    public function label(string $context): string
197
-    {
198
-        $context_label = Registry::elementFactory()->make($context)->label();
199
-
200
-        if ($this->factHasPreciseDate()) {
201
-            if ($this->hasSource()) {
202
-                if ($this->hasSupportingDocument()) {
203
-                    if ($this->sourceMatchesFactDate()) {
204
-                        return I18N::translate('%s sourced with exact certificate', $context_label);
205
-                    } else {
206
-                        return I18N::translate('%s sourced with a certificate', $context_label);
207
-                    }
208
-                }
209
-
210
-                if ($this->sourceMatchesFactDate()) {
211
-                    return I18N::translate('%s precisely sourced', $context_label);
212
-                }
213
-                return I18N::translate('%s sourced', $context_label);
214
-            }
215
-            return I18N::translate('%s not sourced', $context_label);
216
-        }
217
-
218
-        if ($this->factHasDate()) {
219
-            return I18N::translate('%s not precise', $context_label);
220
-        }
221
-        return I18N::translate('%s not found', $context_label);
222
-    }
223
-
224
-    /**
225
-     * {@inheritDoc}
226
-     * @see \MyArtJaub\Webtrees\Module\IsSourced\Data\SourceStatus::order()
227
-     */
228
-    public function order(): int
229
-    {
230
-        return ($this->factHasDate() ? 1 : 0) * ($this->hasSource() ? 1 : -1) *
231
-            ( 1 + ($this->factHasPreciseDate() ? 1 : 0) * (1 +
232
-                0b010 * ($this->sourceMatchesFactDate() ? 1 : 0) +
233
-                0b100 * ($this->hasSupportingDocument() ? 1 : 0)
234
-            )
235
-        );
236
-    }
237
-
238
-    /**
239
-     * {@inheritDoc}
240
-     * @see \MyArtJaub\Webtrees\Module\IsSourced\Data\SourceStatus::combineWith()
241
-     */
242
-    public function combineWith(SourceStatus $other)
243
-    {
244
-        if ($other instanceof FactSourceStatus) {
245
-            $this->addFactHasDate($other->factHasDate());
246
-            $this->addFactHasPreciseDate($other->factHasPreciseDate());
247
-            $this->addSourceHasDate($other->sourceHasDate());
248
-            $this->addSourceMatchesFactDate($other->sourceMatchesFactDate());
249
-        }
250
-
251
-        parent::combineWith($other);
252
-        return $this;
253
-    }
25
+	/**
26
+	 * @var boolean $has_date
27
+	 */
28
+	private $has_date = false;
29
+
30
+	/**
31
+	 * @var boolean $has_precise_date
32
+	 */
33
+	private $has_precise_date = false;
34
+
35
+	/**
36
+	 * @var boolean $has_source_date
37
+	 */
38
+	private $has_source_date = false;
39
+
40
+	/**
41
+	 * @var boolean $source_date_match
42
+	 */
43
+	private $source_date_match = false;
44
+
45
+	/**
46
+	 * Return whether the fact is dated.
47
+	 *
48
+	 * @return bool
49
+	 */
50
+	public function factHasDate(): bool
51
+	{
52
+		return $this->has_date;
53
+	}
54
+
55
+	/**
56
+	 * Set whether the fact is dated.
57
+	 *
58
+	 * @param bool $has_date
59
+	 * @return $this
60
+	 */
61
+	public function setFactHasDate(bool $has_date): self
62
+	{
63
+		$this->has_date = $has_date;
64
+		return $this;
65
+	}
66
+
67
+	/**
68
+	 * Combinate whether the fact is dated with the previous status.
69
+	 *
70
+	 * @param bool $has_date
71
+	 * @return $this
72
+	 */
73
+	public function addFactHasDate(bool $has_date): self
74
+	{
75
+		$this->has_date = $this->has_date || $has_date;
76
+		return $this;
77
+	}
78
+
79
+	/**
80
+	 * Return whether the fact is dated with a precise day.
81
+	 * Any date modifier will be considered as not precise.
82
+	 * A month or year will be considered as not precise.
83
+	 *
84
+	 * @return bool
85
+	 */
86
+	public function factHasPreciseDate(): bool
87
+	{
88
+		return $this->has_date && $this->has_precise_date;
89
+	}
90
+
91
+	/**
92
+	 * Set whather the fact is dated with a precise day.
93
+	 *
94
+	 * @param bool $has_precise_date
95
+	 * @return $this
96
+	 */
97
+	public function setFactHasPreciseDate(bool $has_precise_date): self
98
+	{
99
+		$this->has_precise_date = $has_precise_date;
100
+		return $this;
101
+	}
102
+
103
+	/**
104
+	 * Combine whether the fact is dated with a precise day.
105
+	 *
106
+	 * @param bool $has_precise_date
107
+	 * @return $this
108
+	 */
109
+	public function addFactHasPreciseDate(bool $has_precise_date): self
110
+	{
111
+		$this->has_precise_date = $this->has_precise_date || $has_precise_date;
112
+		return $this;
113
+	}
114
+
115
+	/**
116
+	 * Return whether the source citation is dated.
117
+	 *
118
+	 * @return bool
119
+	 */
120
+	public function sourceHasDate(): bool
121
+	{
122
+		return $this->has_source_date;
123
+	}
124
+
125
+	/**
126
+	 * Set whether the source citation is dated.
127
+	 *
128
+	 * @param bool $has_source_date
129
+	 * @return $this
130
+	 */
131
+	public function setSourceHasDate(bool $has_source_date): self
132
+	{
133
+		$this->has_source_date = $has_source_date;
134
+		return $this;
135
+	}
136
+
137
+	/**
138
+	 * Combine whether the source citation is dated with the previous status.
139
+	 *
140
+	 * @param bool $has_source_date
141
+	 * @return $this
142
+	 */
143
+	public function addSourceHasDate(bool $has_source_date): self
144
+	{
145
+		$this->has_source_date = $this->has_source_date || $has_source_date;
146
+		return $this;
147
+	}
148
+
149
+	/**
150
+	 * Return whether the source citation date is close to the fact date.
151
+	 *
152
+	 * @return bool
153
+	 */
154
+	public function sourceMatchesFactDate(): bool
155
+	{
156
+		return $this->has_precise_date && $this->has_source_date && $this->source_date_match;
157
+	}
158
+
159
+	/**
160
+	 * Set whether the source citation date is close to the fact date.
161
+	 *
162
+	 * @param bool $source_date_match
163
+	 * @return $this
164
+	 */
165
+	public function setSourceMatchesFactDate(bool $source_date_match): self
166
+	{
167
+		$this->source_date_match = $source_date_match;
168
+		return $this;
169
+	}
170
+
171
+	/**
172
+	 * Combine whether the source citation date is close to the fact date with the previous status.
173
+	 *
174
+	 * @param bool $source_date_match
175
+	 * @return $this
176
+	 */
177
+	public function addSourceMatchesFactDate(bool $source_date_match): self
178
+	{
179
+		$this->source_date_match = $this->source_date_match || $source_date_match;
180
+		return $this;
181
+	}
182
+
183
+	/**
184
+	 * {@inheritDoc}
185
+	 * @see \MyArtJaub\Webtrees\Module\IsSourced\Data\SourceStatus::isFullySourced()
186
+	 */
187
+	public function isFullySourced(): bool
188
+	{
189
+		return parent::isFullySourced() && $this->sourceMatchesFactDate();
190
+	}
191
+
192
+	/**
193
+	 * {@inheritDoc}
194
+	 * @see \MyArtJaub\Webtrees\Module\IsSourced\Data\SourceStatus::label()
195
+	 */
196
+	public function label(string $context): string
197
+	{
198
+		$context_label = Registry::elementFactory()->make($context)->label();
199
+
200
+		if ($this->factHasPreciseDate()) {
201
+			if ($this->hasSource()) {
202
+				if ($this->hasSupportingDocument()) {
203
+					if ($this->sourceMatchesFactDate()) {
204
+						return I18N::translate('%s sourced with exact certificate', $context_label);
205
+					} else {
206
+						return I18N::translate('%s sourced with a certificate', $context_label);
207
+					}
208
+				}
209
+
210
+				if ($this->sourceMatchesFactDate()) {
211
+					return I18N::translate('%s precisely sourced', $context_label);
212
+				}
213
+				return I18N::translate('%s sourced', $context_label);
214
+			}
215
+			return I18N::translate('%s not sourced', $context_label);
216
+		}
217
+
218
+		if ($this->factHasDate()) {
219
+			return I18N::translate('%s not precise', $context_label);
220
+		}
221
+		return I18N::translate('%s not found', $context_label);
222
+	}
223
+
224
+	/**
225
+	 * {@inheritDoc}
226
+	 * @see \MyArtJaub\Webtrees\Module\IsSourced\Data\SourceStatus::order()
227
+	 */
228
+	public function order(): int
229
+	{
230
+		return ($this->factHasDate() ? 1 : 0) * ($this->hasSource() ? 1 : -1) *
231
+			( 1 + ($this->factHasPreciseDate() ? 1 : 0) * (1 +
232
+				0b010 * ($this->sourceMatchesFactDate() ? 1 : 0) +
233
+				0b100 * ($this->hasSupportingDocument() ? 1 : 0)
234
+			)
235
+		);
236
+	}
237
+
238
+	/**
239
+	 * {@inheritDoc}
240
+	 * @see \MyArtJaub\Webtrees\Module\IsSourced\Data\SourceStatus::combineWith()
241
+	 */
242
+	public function combineWith(SourceStatus $other)
243
+	{
244
+		if ($other instanceof FactSourceStatus) {
245
+			$this->addFactHasDate($other->factHasDate());
246
+			$this->addFactHasPreciseDate($other->factHasPreciseDate());
247
+			$this->addSourceHasDate($other->sourceHasDate());
248
+			$this->addSourceMatchesFactDate($other->sourceMatchesFactDate());
249
+		}
250
+
251
+		parent::combineWith($other);
252
+		return $this;
253
+	}
254 254
 }
Please login to merge, or discard this patch.
app/Module/IsSourced/Services/SourceStatusService.php 1 patch
Indentation   +122 added lines, -122 removed lines patch added patch discarded remove patch
@@ -29,126 +29,126 @@
 block discarded – undo
29 29
  */
30 30
 class SourceStatusService
31 31
 {
32
-    /**
33
-     * Maximum timespan between the date of a source and the date of the event to consider the source precise.
34
-     * Arbitrally set to approximately a year around the event date.
35
-     *
36
-     * @var int DATE_PRECISION_MARGIN
37
-     */
38
-    private const DATE_PRECISION_MARGIN = 180;
39
-
40
-    /**
41
-     * Return the status of source citations for a fact.
42
-     *
43
-     * @param Fact $fact
44
-     * @return FactSourceStatus
45
-     */
46
-    public function sourceStatusForFact(Fact $fact): FactSourceStatus
47
-    {
48
-        $source_status = new FactSourceStatus();
49
-
50
-        $date = $fact->date();
51
-        $source_status
52
-            ->setFactHasDate($date->isOK())
53
-            ->setFactHasPreciseDate($date->qual1 === '' && $date->minimumJulianDay() === $date->maximumJulianDay());
54
-
55
-        foreach ($fact->getCitations() as $citation) {
56
-            $source_status
57
-                ->setHasSource(true)
58
-                ->addHasSupportingDocument(preg_match('/\n3 _ACT (?:.*)/', $citation) === 1);
59
-
60
-            preg_match_all("/\n3 DATA(?:\n[4-9] .*)*\n4 DATE (.*)/", $citation, $date_matches, PREG_SET_ORDER);
61
-            foreach ($date_matches as $date_match) {
62
-                $source_date = new Date($date_match[1]);
63
-                $source_status
64
-                    ->addSourceHasDate($source_date->isOK())
65
-                    ->addSourceMatchesFactDate($date->isOK() && $source_date->isOK()
66
-                        && abs($source_date->julianDay() - $date->julianDay()) < self::DATE_PRECISION_MARGIN);
67
-            }
68
-
69
-            if ($source_status->isFullySourced()) {
70
-                return $source_status;
71
-            }
72
-        }
73
-
74
-        return $source_status;
75
-    }
76
-
77
-    /**
78
-     * Return the status of sources for a Gedcom record.
79
-     *
80
-     * @param GedcomRecord $record
81
-     * @return SourceStatus
82
-     */
83
-    public function sourceStatusForRecord(GedcomRecord $record): SourceStatus
84
-    {
85
-        $source_status = new SourceStatus();
86
-
87
-        foreach ($record->facts(['SOUR']) as $source) {
88
-            $source_status
89
-                ->setHasSource(true)
90
-                ->addHasSupportingDocument($source->attribute('_ACT') !== '');
91
-
92
-            if ($source_status->isFullySourced()) {
93
-                return $source_status;
94
-            }
95
-        }
96
-
97
-        return $source_status;
98
-    }
99
-
100
-    /**
101
-     * Return the status of source citations for a list of fact types associated with a record.
102
-     *
103
-     * @param GedcomRecord $record
104
-     * @param string[] $tags
105
-     * @return FactSourceStatus
106
-     */
107
-    public function sourceStatusForFactsWithTags(GedcomRecord $record, array $tags): FactSourceStatus
108
-    {
109
-        $source_status = new NullFactSourceStatus();
110
-
111
-        foreach ($record->facts($tags) as $fact) {
112
-            $source_status = $source_status->combineWith($this->sourceStatusForFact($fact));
113
-            if ($source_status->isFullySourced()) {
114
-                return $source_status;
115
-            }
116
-        }
117
-
118
-        return $source_status;
119
-    }
120
-
121
-    /**
122
-     * Return the status of source citations for an individual's birth events.
123
-     *
124
-     * @param Individual $individual
125
-     * @return FactSourceStatus
126
-     */
127
-    public function sourceStatusForBirth(Individual $individual): FactSourceStatus
128
-    {
129
-        return $this->sourceStatusForFactsWithTags($individual, Gedcom::BIRTH_EVENTS);
130
-    }
131
-
132
-    /**
133
-     * Return the status of source citations for an individual's death events.
134
-     *
135
-     * @param Individual $individual
136
-     * @return FactSourceStatus
137
-     */
138
-    public function sourceStatusForDeath(Individual $individual): FactSourceStatus
139
-    {
140
-        return $this->sourceStatusForFactsWithTags($individual, Gedcom::DEATH_EVENTS);
141
-    }
142
-
143
-    /**
144
-     * Return the status of source citations for a family's marriage events.
145
-     *
146
-     * @param Family $family
147
-     * @return FactSourceStatus
148
-     */
149
-    public function sourceStatusForMarriage(Family $family): FactSourceStatus
150
-    {
151
-        $marr_events = [...Gedcom::MARRIAGE_EVENTS, 'MARC', 'MARL', 'MARS'];
152
-        return $this->sourceStatusForFactsWithTags($family, $marr_events);
153
-    }
32
+	/**
33
+	 * Maximum timespan between the date of a source and the date of the event to consider the source precise.
34
+	 * Arbitrally set to approximately a year around the event date.
35
+	 *
36
+	 * @var int DATE_PRECISION_MARGIN
37
+	 */
38
+	private const DATE_PRECISION_MARGIN = 180;
39
+
40
+	/**
41
+	 * Return the status of source citations for a fact.
42
+	 *
43
+	 * @param Fact $fact
44
+	 * @return FactSourceStatus
45
+	 */
46
+	public function sourceStatusForFact(Fact $fact): FactSourceStatus
47
+	{
48
+		$source_status = new FactSourceStatus();
49
+
50
+		$date = $fact->date();
51
+		$source_status
52
+			->setFactHasDate($date->isOK())
53
+			->setFactHasPreciseDate($date->qual1 === '' && $date->minimumJulianDay() === $date->maximumJulianDay());
54
+
55
+		foreach ($fact->getCitations() as $citation) {
56
+			$source_status
57
+				->setHasSource(true)
58
+				->addHasSupportingDocument(preg_match('/\n3 _ACT (?:.*)/', $citation) === 1);
59
+
60
+			preg_match_all("/\n3 DATA(?:\n[4-9] .*)*\n4 DATE (.*)/", $citation, $date_matches, PREG_SET_ORDER);
61
+			foreach ($date_matches as $date_match) {
62
+				$source_date = new Date($date_match[1]);
63
+				$source_status
64
+					->addSourceHasDate($source_date->isOK())
65
+					->addSourceMatchesFactDate($date->isOK() && $source_date->isOK()
66
+						&& abs($source_date->julianDay() - $date->julianDay()) < self::DATE_PRECISION_MARGIN);
67
+			}
68
+
69
+			if ($source_status->isFullySourced()) {
70
+				return $source_status;
71
+			}
72
+		}
73
+
74
+		return $source_status;
75
+	}
76
+
77
+	/**
78
+	 * Return the status of sources for a Gedcom record.
79
+	 *
80
+	 * @param GedcomRecord $record
81
+	 * @return SourceStatus
82
+	 */
83
+	public function sourceStatusForRecord(GedcomRecord $record): SourceStatus
84
+	{
85
+		$source_status = new SourceStatus();
86
+
87
+		foreach ($record->facts(['SOUR']) as $source) {
88
+			$source_status
89
+				->setHasSource(true)
90
+				->addHasSupportingDocument($source->attribute('_ACT') !== '');
91
+
92
+			if ($source_status->isFullySourced()) {
93
+				return $source_status;
94
+			}
95
+		}
96
+
97
+		return $source_status;
98
+	}
99
+
100
+	/**
101
+	 * Return the status of source citations for a list of fact types associated with a record.
102
+	 *
103
+	 * @param GedcomRecord $record
104
+	 * @param string[] $tags
105
+	 * @return FactSourceStatus
106
+	 */
107
+	public function sourceStatusForFactsWithTags(GedcomRecord $record, array $tags): FactSourceStatus
108
+	{
109
+		$source_status = new NullFactSourceStatus();
110
+
111
+		foreach ($record->facts($tags) as $fact) {
112
+			$source_status = $source_status->combineWith($this->sourceStatusForFact($fact));
113
+			if ($source_status->isFullySourced()) {
114
+				return $source_status;
115
+			}
116
+		}
117
+
118
+		return $source_status;
119
+	}
120
+
121
+	/**
122
+	 * Return the status of source citations for an individual's birth events.
123
+	 *
124
+	 * @param Individual $individual
125
+	 * @return FactSourceStatus
126
+	 */
127
+	public function sourceStatusForBirth(Individual $individual): FactSourceStatus
128
+	{
129
+		return $this->sourceStatusForFactsWithTags($individual, Gedcom::BIRTH_EVENTS);
130
+	}
131
+
132
+	/**
133
+	 * Return the status of source citations for an individual's death events.
134
+	 *
135
+	 * @param Individual $individual
136
+	 * @return FactSourceStatus
137
+	 */
138
+	public function sourceStatusForDeath(Individual $individual): FactSourceStatus
139
+	{
140
+		return $this->sourceStatusForFactsWithTags($individual, Gedcom::DEATH_EVENTS);
141
+	}
142
+
143
+	/**
144
+	 * Return the status of source citations for a family's marriage events.
145
+	 *
146
+	 * @param Family $family
147
+	 * @return FactSourceStatus
148
+	 */
149
+	public function sourceStatusForMarriage(Family $family): FactSourceStatus
150
+	{
151
+		$marr_events = [...Gedcom::MARRIAGE_EVENTS, 'MARC', 'MARL', 'MARS'];
152
+		return $this->sourceStatusForFactsWithTags($family, $marr_events);
153
+	}
154 154
 }
Please login to merge, or discard this patch.
app/Common/Hooks/AbstractHookCollector.php 1 patch
Indentation   +67 added lines, -67 removed lines patch added patch discarded remove patch
@@ -27,80 +27,80 @@
 block discarded – undo
27 27
  */
28 28
 abstract class AbstractHookCollector implements HookCollectorInterface, HookInterface
29 29
 {
30
-    /** @var Collection<THook> $hooks */
31
-    protected Collection $hooks;
30
+	/** @var Collection<THook> $hooks */
31
+	protected Collection $hooks;
32 32
 
33
-    private ModuleInterface $module;
33
+	private ModuleInterface $module;
34 34
 
35
-    /**
36
-     * Constructor for AbstractHookCollector
37
-     *
38
-     * @param ModuleInterface $module
39
-     */
40
-    public function __construct(ModuleInterface $module)
41
-    {
42
-        $this->hooks = new Collection();
43
-        $this->module = $module;
44
-    }
35
+	/**
36
+	 * Constructor for AbstractHookCollector
37
+	 *
38
+	 * @param ModuleInterface $module
39
+	 */
40
+	public function __construct(ModuleInterface $module)
41
+	{
42
+		$this->hooks = new Collection();
43
+		$this->module = $module;
44
+	}
45 45
 
46
-    /**
47
-     * {@inheritDoc}
48
-     * @see \MyArtJaub\Webtrees\Contracts\Hooks\HookInterface::module()
49
-     */
50
-    public function module(): ModuleInterface
51
-    {
52
-        return $this->module;
53
-    }
46
+	/**
47
+	 * {@inheritDoc}
48
+	 * @see \MyArtJaub\Webtrees\Contracts\Hooks\HookInterface::module()
49
+	 */
50
+	public function module(): ModuleInterface
51
+	{
52
+		return $this->module;
53
+	}
54 54
 
55
-    /**
56
-     * {@inheritDoc}
57
-     * @see \MyArtJaub\Webtrees\Contracts\Hooks\HookCollectorInterface::name()
58
-     */
59
-    public function name(): string
60
-    {
61
-        return $this->module->name() . '-' .
62
-            mb_substr(str_replace('collector', '', mb_strtolower((new ReflectionClass($this))->getShortName())), 0, 64);
63
-    }
55
+	/**
56
+	 * {@inheritDoc}
57
+	 * @see \MyArtJaub\Webtrees\Contracts\Hooks\HookCollectorInterface::name()
58
+	 */
59
+	public function name(): string
60
+	{
61
+		return $this->module->name() . '-' .
62
+			mb_substr(str_replace('collector', '', mb_strtolower((new ReflectionClass($this))->getShortName())), 0, 64);
63
+	}
64 64
 
65
-    /**
66
-     * {@inheritDoc}
67
-     * @see \MyArtJaub\Webtrees\Contracts\Hooks\HookCollectorInterface::title()
68
-     */
69
-    abstract public function title(): string;
65
+	/**
66
+	 * {@inheritDoc}
67
+	 * @see \MyArtJaub\Webtrees\Contracts\Hooks\HookCollectorInterface::title()
68
+	 */
69
+	abstract public function title(): string;
70 70
 
71
-    /**
72
-     * {@inheritDoc}
73
-     * @see \MyArtJaub\Webtrees\Contracts\Hooks\HookCollectorInterface::description()
74
-     */
75
-    abstract public function description(): string;
71
+	/**
72
+	 * {@inheritDoc}
73
+	 * @see \MyArtJaub\Webtrees\Contracts\Hooks\HookCollectorInterface::description()
74
+	 */
75
+	abstract public function description(): string;
76 76
 
77
-    /**
78
-     * {@inheritDoc}
79
-     * @see \MyArtJaub\Webtrees\Contracts\Hooks\HookCollectorInterface::hookInterface()
80
-     */
81
-    abstract public function hookInterface(): string;
77
+	/**
78
+	 * {@inheritDoc}
79
+	 * @see \MyArtJaub\Webtrees\Contracts\Hooks\HookCollectorInterface::hookInterface()
80
+	 */
81
+	abstract public function hookInterface(): string;
82 82
 
83
-    /**
84
-     * {@inheritDoc}
85
-     * @see \MyArtJaub\Webtrees\Contracts\Hooks\HookCollectorInterface::register()
86
-     */
87
-    public function register(HookInterface $hook_instance, int $order): void
88
-    {
89
-        if ($this->hooks->has($order)) {
90
-            $this->hooks->splice($order + 1, 0, [$hook_instance]);
91
-        } else {
92
-            $this->hooks->put($order, $hook_instance);
93
-        }
94
-    }
83
+	/**
84
+	 * {@inheritDoc}
85
+	 * @see \MyArtJaub\Webtrees\Contracts\Hooks\HookCollectorInterface::register()
86
+	 */
87
+	public function register(HookInterface $hook_instance, int $order): void
88
+	{
89
+		if ($this->hooks->has($order)) {
90
+			$this->hooks->splice($order + 1, 0, [$hook_instance]);
91
+		} else {
92
+			$this->hooks->put($order, $hook_instance);
93
+		}
94
+	}
95 95
 
96
-    /**
97
-     * {@inheritDoc}
98
-     * @see \MyArtJaub\Webtrees\Contracts\Hooks\HookCollectorInterface::hooks()
99
-     *
100
-     * @return Collection<THook>
101
-     */
102
-    public function hooks(): Collection
103
-    {
104
-        return $this->hooks->sortKeys();
105
-    }
96
+	/**
97
+	 * {@inheritDoc}
98
+	 * @see \MyArtJaub\Webtrees\Contracts\Hooks\HookCollectorInterface::hooks()
99
+	 *
100
+	 * @return Collection<THook>
101
+	 */
102
+	public function hooks(): Collection
103
+	{
104
+		return $this->hooks->sortKeys();
105
+	}
106 106
 }
Please login to merge, or discard this patch.
app/Common/GeoDispersion/GeoAnalysis/GeoAnalysisPlace.php 1 patch
Indentation   +129 added lines, -129 removed lines patch added patch discarded remove patch
@@ -28,133 +28,133 @@
 block discarded – undo
28 28
  */
29 29
 class GeoAnalysisPlace
30 30
 {
31
-    /**
32
-     * The default place name for invalid places
33
-     * @var string INVALID_PLACE
34
-     */
35
-    private const INVALID_PLACE = '##INVALID##';
36
-
37
-    private Place $place;
38
-    private bool $is_excluded;
39
-
40
-    /**
41
-     * Constructor for GeoAnalysisPlace
42
-     *
43
-     * @param Tree $tree Default tree
44
-     * @param Place|null $place Place resulting from the analysis
45
-     * @param int $depth Place hierarchy depth defined by the geographical analysis view
46
-     * @param bool $strict_depth Checks whether places with a lower depth than defined should be flagged as invalid
47
-     */
48
-    public function __construct(Tree $tree, ?Place $place, int $depth, bool $strict_depth = false)
49
-    {
50
-        $this->place = $this->extractPlace($place, $depth, $strict_depth) ?? new Place('', $tree);
51
-        $this->is_excluded = false;
52
-    }
53
-
54
-    /**
55
-     * Process the provided Place to determine its status for further usage
56
-     *
57
-     * @param Place|null $place
58
-     * @param int $depth
59
-     * @param bool $strict_depth
60
-     * @return Place|NULL
61
-     */
62
-    private function extractPlace(?Place $place, int $depth, bool $strict_depth): ?Place
63
-    {
64
-        if ($place === null) {
65
-            return null;
66
-        }
67
-        if (mb_strlen($place->gedcomName()) === 0) {
68
-            return null;
69
-        }
70
-        $parts = $place->lastParts($depth);
71
-        if ($strict_depth && $parts->count() !== $depth) {
72
-            return new Place(self::INVALID_PLACE, $place->tree());
73
-        }
74
-        return new Place($parts->implode(', '), $place->tree());
75
-    }
76
-
77
-    /**
78
-     * Get the GeoAnalysis Place key
79
-     *
80
-     * @return string
81
-     */
82
-    public function key(): string
83
-    {
84
-        return $this->place->gedcomName();
85
-    }
86
-
87
-    /**
88
-     * Get the underlying Place object
89
-     *
90
-     * @return Place
91
-     */
92
-    public function place(): Place
93
-    {
94
-        return $this->place;
95
-    }
96
-
97
-    /**
98
-     * Check if the GeoAnalysis Place is in the Known status
99
-     *
100
-     * @return bool
101
-     */
102
-    public function isKnown(): bool
103
-    {
104
-        return !$this->isUnknown();
105
-    }
106
-
107
-    /**
108
-     * Check if the GeoAnalysis Place is in the Unknown status
109
-     *
110
-     * @return bool
111
-     */
112
-    public function isUnknown(): bool
113
-    {
114
-        return mb_strlen($this->place->gedcomName()) === 0;
115
-    }
116
-
117
-    /**
118
-     * Check if the GeoAnalysis Place is in the Invalid status
119
-     *
120
-     * @return bool
121
-     */
122
-    public function isInvalid(): bool
123
-    {
124
-        return $this->place->gedcomName() === self::INVALID_PLACE;
125
-    }
126
-
127
-    /**
128
-     * Check if the GeoAnalysis Place is in the Excluded status
129
-     *
130
-     * @return bool
131
-     */
132
-    public function isExcluded(): bool
133
-    {
134
-        return $this->isUnknown() || $this->isInvalid() || $this->is_excluded;
135
-    }
136
-
137
-    /**
138
-     * Set the GeoAnalysis Place status to Found, if the parameter is true
139
-     *
140
-     * @param bool $include
141
-     * @return $this
142
-     */
143
-    public function include(bool $include = true): self
144
-    {
145
-        $this->is_excluded = !$include;
146
-        return $this;
147
-    }
148
-
149
-    /**
150
-     * Set the GeoAnalysis Place status to Excluded, if the parameter is true
151
-     *
152
-     * @param bool $exclude
153
-     * @return $this
154
-     */
155
-    public function exclude(bool $exclude = true): self
156
-    {
157
-        $this->is_excluded = $exclude;
158
-        return $this;
159
-    }
31
+	/**
32
+	 * The default place name for invalid places
33
+	 * @var string INVALID_PLACE
34
+	 */
35
+	private const INVALID_PLACE = '##INVALID##';
36
+
37
+	private Place $place;
38
+	private bool $is_excluded;
39
+
40
+	/**
41
+	 * Constructor for GeoAnalysisPlace
42
+	 *
43
+	 * @param Tree $tree Default tree
44
+	 * @param Place|null $place Place resulting from the analysis
45
+	 * @param int $depth Place hierarchy depth defined by the geographical analysis view
46
+	 * @param bool $strict_depth Checks whether places with a lower depth than defined should be flagged as invalid
47
+	 */
48
+	public function __construct(Tree $tree, ?Place $place, int $depth, bool $strict_depth = false)
49
+	{
50
+		$this->place = $this->extractPlace($place, $depth, $strict_depth) ?? new Place('', $tree);
51
+		$this->is_excluded = false;
52
+	}
53
+
54
+	/**
55
+	 * Process the provided Place to determine its status for further usage
56
+	 *
57
+	 * @param Place|null $place
58
+	 * @param int $depth
59
+	 * @param bool $strict_depth
60
+	 * @return Place|NULL
61
+	 */
62
+	private function extractPlace(?Place $place, int $depth, bool $strict_depth): ?Place
63
+	{
64
+		if ($place === null) {
65
+			return null;
66
+		}
67
+		if (mb_strlen($place->gedcomName()) === 0) {
68
+			return null;
69
+		}
70
+		$parts = $place->lastParts($depth);
71
+		if ($strict_depth && $parts->count() !== $depth) {
72
+			return new Place(self::INVALID_PLACE, $place->tree());
73
+		}
74
+		return new Place($parts->implode(', '), $place->tree());
75
+	}
76
+
77
+	/**
78
+	 * Get the GeoAnalysis Place key
79
+	 *
80
+	 * @return string
81
+	 */
82
+	public function key(): string
83
+	{
84
+		return $this->place->gedcomName();
85
+	}
86
+
87
+	/**
88
+	 * Get the underlying Place object
89
+	 *
90
+	 * @return Place
91
+	 */
92
+	public function place(): Place
93
+	{
94
+		return $this->place;
95
+	}
96
+
97
+	/**
98
+	 * Check if the GeoAnalysis Place is in the Known status
99
+	 *
100
+	 * @return bool
101
+	 */
102
+	public function isKnown(): bool
103
+	{
104
+		return !$this->isUnknown();
105
+	}
106
+
107
+	/**
108
+	 * Check if the GeoAnalysis Place is in the Unknown status
109
+	 *
110
+	 * @return bool
111
+	 */
112
+	public function isUnknown(): bool
113
+	{
114
+		return mb_strlen($this->place->gedcomName()) === 0;
115
+	}
116
+
117
+	/**
118
+	 * Check if the GeoAnalysis Place is in the Invalid status
119
+	 *
120
+	 * @return bool
121
+	 */
122
+	public function isInvalid(): bool
123
+	{
124
+		return $this->place->gedcomName() === self::INVALID_PLACE;
125
+	}
126
+
127
+	/**
128
+	 * Check if the GeoAnalysis Place is in the Excluded status
129
+	 *
130
+	 * @return bool
131
+	 */
132
+	public function isExcluded(): bool
133
+	{
134
+		return $this->isUnknown() || $this->isInvalid() || $this->is_excluded;
135
+	}
136
+
137
+	/**
138
+	 * Set the GeoAnalysis Place status to Found, if the parameter is true
139
+	 *
140
+	 * @param bool $include
141
+	 * @return $this
142
+	 */
143
+	public function include(bool $include = true): self
144
+	{
145
+		$this->is_excluded = !$include;
146
+		return $this;
147
+	}
148
+
149
+	/**
150
+	 * Set the GeoAnalysis Place status to Excluded, if the parameter is true
151
+	 *
152
+	 * @param bool $exclude
153
+	 * @return $this
154
+	 */
155
+	public function exclude(bool $exclude = true): self
156
+	{
157
+		$this->is_excluded = $exclude;
158
+		return $this;
159
+	}
160 160
 }
Please login to merge, or discard this patch.
app/Common/GeoDispersion/GeoAnalysis/GeoAnalysisResultItem.php 1 patch
Indentation   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -20,67 +20,67 @@
 block discarded – undo
20 20
  */
21 21
 class GeoAnalysisResultItem
22 22
 {
23
-    private GeoAnalysisPlace $place;
24
-    private int $count;
23
+	private GeoAnalysisPlace $place;
24
+	private int $count;
25 25
 
26
-    /**
27
-     * Constructor for GeoAnalysisResultItem
28
-     *
29
-     * @param GeoAnalysisPlace $place
30
-     * @param int $count
31
-     */
32
-    public function __construct(GeoAnalysisPlace $place, int $count = 0)
33
-    {
34
-        $this->place = $place;
35
-        $this->count = $count;
36
-    }
26
+	/**
27
+	 * Constructor for GeoAnalysisResultItem
28
+	 *
29
+	 * @param GeoAnalysisPlace $place
30
+	 * @param int $count
31
+	 */
32
+	public function __construct(GeoAnalysisPlace $place, int $count = 0)
33
+	{
34
+		$this->place = $place;
35
+		$this->count = $count;
36
+	}
37 37
 
38
-    /**
39
-     * Get the item key.
40
-     *
41
-     * @return string
42
-     */
43
-    public function key(): string
44
-    {
45
-        return $this->place->key();
46
-    }
38
+	/**
39
+	 * Get the item key.
40
+	 *
41
+	 * @return string
42
+	 */
43
+	public function key(): string
44
+	{
45
+		return $this->place->key();
46
+	}
47 47
 
48
-    /**
49
-     * Get the referenced GeoAnalysis Place
50
-     *
51
-     * @return GeoAnalysisPlace
52
-     */
53
-    public function place(): GeoAnalysisPlace
54
-    {
55
-        return $this->place;
56
-    }
48
+	/**
49
+	 * Get the referenced GeoAnalysis Place
50
+	 *
51
+	 * @return GeoAnalysisPlace
52
+	 */
53
+	public function place(): GeoAnalysisPlace
54
+	{
55
+		return $this->place;
56
+	}
57 57
 
58
-    /**
59
-     * Get the count of occurrences of the GeoAnalysis Place in the analysis
60
-     *
61
-     * @return int
62
-     */
63
-    public function count(): int
64
-    {
65
-        return $this->count;
66
-    }
58
+	/**
59
+	 * Get the count of occurrences of the GeoAnalysis Place in the analysis
60
+	 *
61
+	 * @return int
62
+	 */
63
+	public function count(): int
64
+	{
65
+		return $this->count;
66
+	}
67 67
 
68
-    /**
69
-     * Increment the count of occurrences of the GeoAnalysis Place in the analysis
70
-     *
71
-     * @return $this
72
-     */
73
-    public function increment(): self
74
-    {
75
-        $this->count++;
76
-        return $this;
77
-    }
68
+	/**
69
+	 * Increment the count of occurrences of the GeoAnalysis Place in the analysis
70
+	 *
71
+	 * @return $this
72
+	 */
73
+	public function increment(): self
74
+	{
75
+		$this->count++;
76
+		return $this;
77
+	}
78 78
 
79
-    /**
80
-     * Clone the item object
81
-     */
82
-    public function __clone()
83
-    {
84
-        $this->place = clone $this->place;
85
-    }
79
+	/**
80
+	 * Clone the item object
81
+	 */
82
+	public function __clone()
83
+	{
84
+		$this->place = clone $this->place;
85
+	}
86 86
 }
Please login to merge, or discard this patch.
app/Http/Middleware/AuthTreePreference.php 1 patch
Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -31,40 +31,40 @@
 block discarded – undo
31 31
  */
32 32
 class AuthTreePreference implements MiddlewareInterface
33 33
 {
34
-    /**
35
-     * {@inheritDoc}
36
-     * @see \Psr\Http\Server\MiddlewareInterface::process()
37
-     */
38
-    public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
39
-    {
40
-        $tree = Validator::attributes($request)->tree();
41
-        $route = Validator::attributes($request)->route();
42
-        $user = Validator::attributes($request)->user();
34
+	/**
35
+	 * {@inheritDoc}
36
+	 * @see \Psr\Http\Server\MiddlewareInterface::process()
37
+	 */
38
+	public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
39
+	{
40
+		$tree = Validator::attributes($request)->tree();
41
+		$route = Validator::attributes($request)->route();
42
+		$user = Validator::attributes($request)->user();
43 43
 
44
-        $permission_preference = $route->extras['permission_preference'] ?? '';
45
-        $permission_level = $permission_preference === '' ? '' : $tree->getPreference($permission_preference);
44
+		$permission_preference = $route->extras['permission_preference'] ?? '';
45
+		$permission_level = $permission_preference === '' ? '' : $tree->getPreference($permission_preference);
46 46
 
47
-        // Permissions are configured
48
-        if (is_numeric($permission_level)) {
49
-            // Logged in with the correct role?
50
-            if (Auth::accessLevel($tree, $user) <= (int) $permission_level) {
51
-                    return $handler->handle($request);
52
-            }
47
+		// Permissions are configured
48
+		if (is_numeric($permission_level)) {
49
+			// Logged in with the correct role?
50
+			if (Auth::accessLevel($tree, $user) <= (int) $permission_level) {
51
+					return $handler->handle($request);
52
+			}
53 53
 
54
-            // Logged in, but without the correct role?
55
-            if ($user instanceof User) {
56
-                throw new HttpAccessDeniedException();
57
-            }
58
-        }
54
+			// Logged in, but without the correct role?
55
+			if ($user instanceof User) {
56
+				throw new HttpAccessDeniedException();
57
+			}
58
+		}
59 59
 
60
-        // Permissions no configured, or not logged in
61
-        if ($request->getMethod() === RequestMethodInterface::METHOD_POST) {
62
-            throw new HttpAccessDeniedException();
63
-        }
60
+		// Permissions no configured, or not logged in
61
+		if ($request->getMethod() === RequestMethodInterface::METHOD_POST) {
62
+			throw new HttpAccessDeniedException();
63
+		}
64 64
 
65
-        return Registry::responseFactory()->redirect(
66
-            LoginPage::class,
67
-            ['tree' => $tree->name(), 'url' => (string) $request->getUri()]
68
-        );
69
-    }
65
+		return Registry::responseFactory()->redirect(
66
+			LoginPage::class,
67
+			['tree' => $tree->name(), 'url' => (string) $request->getUri()]
68
+		);
69
+	}
70 70
 }
Please login to merge, or discard this patch.
app/Common/Tasks/TaskSchedule.php 1 patch
Indentation   +229 added lines, -229 removed lines patch added patch discarded remove patch
@@ -23,252 +23,252 @@
 block discarded – undo
23 23
  */
24 24
 class TaskSchedule
25 25
 {
26
-    private int $id;
27
-    private bool $enabled;
28
-    private string $task_id;
29
-    private CarbonInterface $last_run;
30
-    private bool $last_result;
31
-    private int $frequency;
32
-    private int $nb_occurrences;
33
-    private bool $is_running;
26
+	private int $id;
27
+	private bool $enabled;
28
+	private string $task_id;
29
+	private CarbonInterface $last_run;
30
+	private bool $last_result;
31
+	private int $frequency;
32
+	private int $nb_occurrences;
33
+	private bool $is_running;
34 34
 
35
-    /**
36
-     * Constructor for TaskSchedule
37
-     *
38
-     * @param int $id Schedule ID
39
-     * @param string $task_id Task ID
40
-     * @param bool $enabled Is the schedule enabled
41
-     * @param CarbonInterface $last_run Last successful run date/time
42
-     * @param bool $last_result Result of the last run
43
-     * @param int $frequency Schedule frequency in minutes
44
-     * @param int $nb_occurrences Number of remaining occurrences to be run
45
-     * @param bool $is_running Is the task currently running
46
-     */
47
-    public function __construct(
48
-        int $id,
49
-        string $task_id,
50
-        bool $enabled,
51
-        CarbonInterface $last_run,
52
-        bool $last_result,
53
-        int $frequency,
54
-        int $nb_occurrences,
55
-        bool $is_running
56
-    ) {
57
-        $this->id = $id;
58
-        $this->task_id = $task_id;
59
-        $this->enabled = $enabled;
60
-        $this->last_run = $last_run;
61
-        $this->last_result = $last_result;
62
-        $this->frequency = $frequency;
63
-        $this->nb_occurrences = $nb_occurrences;
64
-        $this->is_running = $is_running;
65
-    }
35
+	/**
36
+	 * Constructor for TaskSchedule
37
+	 *
38
+	 * @param int $id Schedule ID
39
+	 * @param string $task_id Task ID
40
+	 * @param bool $enabled Is the schedule enabled
41
+	 * @param CarbonInterface $last_run Last successful run date/time
42
+	 * @param bool $last_result Result of the last run
43
+	 * @param int $frequency Schedule frequency in minutes
44
+	 * @param int $nb_occurrences Number of remaining occurrences to be run
45
+	 * @param bool $is_running Is the task currently running
46
+	 */
47
+	public function __construct(
48
+		int $id,
49
+		string $task_id,
50
+		bool $enabled,
51
+		CarbonInterface $last_run,
52
+		bool $last_result,
53
+		int $frequency,
54
+		int $nb_occurrences,
55
+		bool $is_running
56
+	) {
57
+		$this->id = $id;
58
+		$this->task_id = $task_id;
59
+		$this->enabled = $enabled;
60
+		$this->last_run = $last_run;
61
+		$this->last_result = $last_result;
62
+		$this->frequency = $frequency;
63
+		$this->nb_occurrences = $nb_occurrences;
64
+		$this->is_running = $is_running;
65
+	}
66 66
 
67
-    /**
68
-     * Get the schedule ID.
69
-     *
70
-     * @return int
71
-     */
72
-    public function id(): int
73
-    {
74
-        return $this->id;
75
-    }
67
+	/**
68
+	 * Get the schedule ID.
69
+	 *
70
+	 * @return int
71
+	 */
72
+	public function id(): int
73
+	{
74
+		return $this->id;
75
+	}
76 76
 
77
-    /**
78
-     * Get the task ID.
79
-     *
80
-     * @return string
81
-     */
82
-    public function taskId(): string
83
-    {
84
-        return $this->task_id;
85
-    }
77
+	/**
78
+	 * Get the task ID.
79
+	 *
80
+	 * @return string
81
+	 */
82
+	public function taskId(): string
83
+	{
84
+		return $this->task_id;
85
+	}
86 86
 
87
-    /**
88
-     * Returns whether the schedule is enabled
89
-     *
90
-     * @return bool
91
-     */
92
-    public function isEnabled(): bool
93
-    {
94
-        return $this->enabled;
95
-    }
87
+	/**
88
+	 * Returns whether the schedule is enabled
89
+	 *
90
+	 * @return bool
91
+	 */
92
+	public function isEnabled(): bool
93
+	{
94
+		return $this->enabled;
95
+	}
96 96
 
97
-    /**
98
-     * Enable the schedule
99
-     *
100
-     * @return $this
101
-     */
102
-    public function enable(): self
103
-    {
104
-        $this->enabled = true;
105
-        return $this;
106
-    }
97
+	/**
98
+	 * Enable the schedule
99
+	 *
100
+	 * @return $this
101
+	 */
102
+	public function enable(): self
103
+	{
104
+		$this->enabled = true;
105
+		return $this;
106
+	}
107 107
 
108
-    /**
109
-     * Disable the schedule
110
-     *
111
-     * @return $this
112
-     */
113
-    public function disable(): self
114
-    {
115
-        $this->enabled = false;
116
-        return $this;
117
-    }
108
+	/**
109
+	 * Disable the schedule
110
+	 *
111
+	 * @return $this
112
+	 */
113
+	public function disable(): self
114
+	{
115
+		$this->enabled = false;
116
+		return $this;
117
+	}
118 118
 
119
-    /**
120
-     * Get the frequency of the schedule
121
-     *
122
-     * @return int
123
-     */
124
-    public function frequency(): int
125
-    {
126
-        return $this->frequency;
127
-    }
119
+	/**
120
+	 * Get the frequency of the schedule
121
+	 *
122
+	 * @return int
123
+	 */
124
+	public function frequency(): int
125
+	{
126
+		return $this->frequency;
127
+	}
128 128
 
129
-    /**
130
-     * Set the frequency of the schedule
131
-     *
132
-     * @param int $frequency
133
-     * @return $this
134
-     */
135
-    public function setFrequency(int $frequency): self
136
-    {
137
-        $this->frequency = $frequency;
138
-        return $this;
139
-    }
129
+	/**
130
+	 * Set the frequency of the schedule
131
+	 *
132
+	 * @param int $frequency
133
+	 * @return $this
134
+	 */
135
+	public function setFrequency(int $frequency): self
136
+	{
137
+		$this->frequency = $frequency;
138
+		return $this;
139
+	}
140 140
 
141
-    /**
142
-     * Get the date/time of the last successful run.
143
-     *
144
-     * @return CarbonInterface
145
-     */
146
-    public function lastRunTime(): CarbonInterface
147
-    {
148
-        return $this->last_run;
149
-    }
141
+	/**
142
+	 * Get the date/time of the last successful run.
143
+	 *
144
+	 * @return CarbonInterface
145
+	 */
146
+	public function lastRunTime(): CarbonInterface
147
+	{
148
+		return $this->last_run;
149
+	}
150 150
 
151
-    /**
152
-     * Set the last successful run date/time
153
-     *
154
-     * @param CarbonInterface $last_run
155
-     * @return $this
156
-     */
157
-    public function setLastRunTime(CarbonInterface $last_run): self
158
-    {
159
-        $this->last_run = $last_run;
160
-        return $this;
161
-    }
151
+	/**
152
+	 * Set the last successful run date/time
153
+	 *
154
+	 * @param CarbonInterface $last_run
155
+	 * @return $this
156
+	 */
157
+	public function setLastRunTime(CarbonInterface $last_run): self
158
+	{
159
+		$this->last_run = $last_run;
160
+		return $this;
161
+	}
162 162
 
163
-    /**
164
-     * Returns whether the last run was successful
165
-     *
166
-     * @return bool
167
-     */
168
-    public function wasLastRunSuccess(): bool
169
-    {
170
-        return $this->last_result;
171
-    }
163
+	/**
164
+	 * Returns whether the last run was successful
165
+	 *
166
+	 * @return bool
167
+	 */
168
+	public function wasLastRunSuccess(): bool
169
+	{
170
+		return $this->last_result;
171
+	}
172 172
 
173
-    /**
174
-     * Set the last run result
175
-     *
176
-     * @param bool $last_result
177
-     * @return $this
178
-     */
179
-    public function setLastResult(bool $last_result): self
180
-    {
181
-        $this->last_result = $last_result;
182
-        return $this;
183
-    }
173
+	/**
174
+	 * Set the last run result
175
+	 *
176
+	 * @param bool $last_result
177
+	 * @return $this
178
+	 */
179
+	public function setLastResult(bool $last_result): self
180
+	{
181
+		$this->last_result = $last_result;
182
+		return $this;
183
+	}
184 184
 
185
-    /**
186
-     * Get the number of remaining of occurrences of task runs.
187
-     * Returns 0 if the tasks must be run indefinitely.
188
-     *
189
-     * @return int
190
-     */
191
-    public function remainingOccurrences(): int
192
-    {
193
-        return $this->nb_occurrences;
194
-    }
185
+	/**
186
+	 * Get the number of remaining of occurrences of task runs.
187
+	 * Returns 0 if the tasks must be run indefinitely.
188
+	 *
189
+	 * @return int
190
+	 */
191
+	public function remainingOccurrences(): int
192
+	{
193
+		return $this->nb_occurrences;
194
+	}
195 195
 
196
-    /**
197
-     * Decrements the number of remaining occurrences by 1.
198
-     * The task will be disabled when the number reaches 0.
199
-     *
200
-     * @return $this
201
-     */
202
-    public function decrementRemainingOccurrences(): self
203
-    {
204
-        if ($this->nb_occurrences > 0) {
205
-            $this->nb_occurrences--;
206
-            if ($this->nb_occurrences === 0) {
207
-                $this->disable();
208
-            }
209
-        }
210
-        return $this;
211
-    }
196
+	/**
197
+	 * Decrements the number of remaining occurrences by 1.
198
+	 * The task will be disabled when the number reaches 0.
199
+	 *
200
+	 * @return $this
201
+	 */
202
+	public function decrementRemainingOccurrences(): self
203
+	{
204
+		if ($this->nb_occurrences > 0) {
205
+			$this->nb_occurrences--;
206
+			if ($this->nb_occurrences === 0) {
207
+				$this->disable();
208
+			}
209
+		}
210
+		return $this;
211
+	}
212 212
 
213
-    /**
214
-     * Set the number of remaining occurrences of task runs.
215
-     *
216
-     * @param int $nb_occurrences
217
-     * @return $this
218
-     */
219
-    public function setRemainingOccurrences(int $nb_occurrences): self
220
-    {
221
-        $this->nb_occurrences = $nb_occurrences;
222
-        return $this;
223
-    }
213
+	/**
214
+	 * Set the number of remaining occurrences of task runs.
215
+	 *
216
+	 * @param int $nb_occurrences
217
+	 * @return $this
218
+	 */
219
+	public function setRemainingOccurrences(int $nb_occurrences): self
220
+	{
221
+		$this->nb_occurrences = $nb_occurrences;
222
+		return $this;
223
+	}
224 224
 
225
-    /**
226
-     * Returns whether the task is running
227
-     * @return bool
228
-     */
229
-    public function isRunning(): bool
230
-    {
231
-        return $this->is_running;
232
-    }
225
+	/**
226
+	 * Returns whether the task is running
227
+	 * @return bool
228
+	 */
229
+	public function isRunning(): bool
230
+	{
231
+		return $this->is_running;
232
+	}
233 233
 
234
-    /**
235
-     * Informs the schedule that the task is going to run
236
-     *
237
-     * @return $this
238
-     */
239
-    public function startRunning(): self
240
-    {
241
-        $this->is_running = true;
242
-        return $this;
243
-    }
234
+	/**
235
+	 * Informs the schedule that the task is going to run
236
+	 *
237
+	 * @return $this
238
+	 */
239
+	public function startRunning(): self
240
+	{
241
+		$this->is_running = true;
242
+		return $this;
243
+	}
244 244
 
245
-    /**
246
-     * Informs the schedule that the task has stopped running.
247
-     * @return $this
248
-     */
249
-    public function stopRunning(): self
250
-    {
251
-        $this->is_running = false;
252
-        return $this;
253
-    }
245
+	/**
246
+	 * Informs the schedule that the task has stopped running.
247
+	 * @return $this
248
+	 */
249
+	public function stopRunning(): self
250
+	{
251
+		$this->is_running = false;
252
+		return $this;
253
+	}
254 254
 
255
-    /**
256
-     * Returns the schedule details as an associate array
257
-     *
258
-     * @phpcs:ignore Generic.Files.LineLength.TooLong
259
-     * @return array{id: int, task_id: string, enabled: bool, last_run: CarbonInterface, last_result: bool, frequency: int, nb_occurrences: int, is_running: bool}
260
-     */
261
-    public function toArray(): array
262
-    {
263
-        return [
264
-            'id'            =>  $this->id,
265
-            'task_id'       =>  $this->task_id,
266
-            'enabled'       =>  $this->enabled,
267
-            'last_run'      =>  $this->last_run,
268
-            'last_result'   =>  $this->last_result,
269
-            'frequency'     =>  $this->frequency,
270
-            'nb_occurrences' =>  $this->nb_occurrences,
271
-            'is_running'    =>  $this->is_running
272
-        ];
273
-    }
255
+	/**
256
+	 * Returns the schedule details as an associate array
257
+	 *
258
+	 * @phpcs:ignore Generic.Files.LineLength.TooLong
259
+	 * @return array{id: int, task_id: string, enabled: bool, last_run: CarbonInterface, last_result: bool, frequency: int, nb_occurrences: int, is_running: bool}
260
+	 */
261
+	public function toArray(): array
262
+	{
263
+		return [
264
+			'id'            =>  $this->id,
265
+			'task_id'       =>  $this->task_id,
266
+			'enabled'       =>  $this->enabled,
267
+			'last_run'      =>  $this->last_run,
268
+			'last_result'   =>  $this->last_result,
269
+			'frequency'     =>  $this->frequency,
270
+			'nb_occurrences' =>  $this->nb_occurrences,
271
+			'is_running'    =>  $this->is_running
272
+		];
273
+	}
274 274
 }
Please login to merge, or discard this patch.
app/Module/Sosa/Http/RequestHandlers/SosaComputeModal.php 1 patch
Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -28,39 +28,39 @@
 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 Registry::responseFactory()->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 Registry::responseFactory()->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 = Validator::attributes($request)->tree();
59
+		$tree = Validator::attributes($request)->tree();
60 60
 
61
-        return Registry::responseFactory()->response(view($this->module->name() . '::modals/sosa-compute', [
62
-            'tree'          => $tree,
63
-            'xref'          => Validator::attributes($request)->isXref()->string('xref', '')
64
-        ]));
65
-    }
61
+		return Registry::responseFactory()->response(view($this->module->name() . '::modals/sosa-compute', [
62
+			'tree'          => $tree,
63
+			'xref'          => Validator::attributes($request)->isXref()->string('xref', '')
64
+		]));
65
+	}
66 66
 }
Please login to merge, or discard this patch.