Passed
Push — 5.x ( 64edde...71aac6 )
by Jeroen
12:33 queued 14s
created

PrepareSecurityTxt   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 15
c 1
b 0
f 1
dl 0
loc 28
ccs 0
cts 16
cp 0
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 19 2
1
<?php
2
3
namespace Elgg\Forms;
4
5
/**
6
 * Prepare the form fields for admin/security/security_txt
7
 *
8
 * @since 5.1
9
 */
10
class PrepareSecurityTxt {
11
	
12
	/**
13
	 * Prepare the form fields
14
	 *
15
	 * @param \Elgg\Event $event 'form:prepare:fields', 'admin/security/security_txt'
16
	 *
17
	 * @return array
18
	 */
19
	public function __invoke(\Elgg\Event $event): array {
20
		$body_vars = $event->getValue();
21
		
22
		$fields = [
23
			'contact',
24
			'expires',
25
			'encryption',
26
			'acknowledgments',
27
			'language',
28
			'canonical',
29
			'policy',
30
			'hiring',
31
			'csaf',
32
		];
33
		foreach ($fields as $field) {
34
			$body_vars[$field] = elgg_extract($field, $body_vars, elgg_get_config("security_txt_{$field}"));
35
		}
36
		
37
		return $body_vars;
38
	}
39
}
40