@@ 24-62 (lines=39) @@ | ||
21 | * @link https://packagist.org/packages/austinheap/php-security-txt |
|
22 | * @link https://austinheap.github.io/php-security-txt/classes/AustinHeap.Security.Txt.SecurityTxt.html |
|
23 | */ |
|
24 | trait Acknowledgement |
|
25 | { |
|
26 | ||
27 | /** |
|
28 | * The acknowledgement URL. |
|
29 | * |
|
30 | * @var string |
|
31 | */ |
|
32 | protected $acknowledgement = null; |
|
33 | ||
34 | /** |
|
35 | * Set the acknowledgement URL. |
|
36 | * |
|
37 | * @param string $acknowledgement |
|
38 | * |
|
39 | * @return SecurityTxt |
|
40 | */ |
|
41 | public function setAcknowledgement(string $acknowledgement): SecurityTxt |
|
42 | { |
|
43 | if (filter_var($acknowledgement, FILTER_VALIDATE_URL) === false) { |
|
44 | throw new Exception('Acknowledgement must be a well-formed URL.'); |
|
45 | } |
|
46 | ||
47 | $this->acknowledgement = $acknowledgement; |
|
48 | ||
49 | return $this; |
|
50 | } |
|
51 | ||
52 | /** |
|
53 | * Get the acknowledgement URL. |
|
54 | * |
|
55 | * @return string |
|
56 | */ |
|
57 | public function getAcknowledgement(): string |
|
58 | { |
|
59 | return $this->acknowledgement; |
|
60 | } |
|
61 | ||
62 | } |
|
63 |
@@ 24-75 (lines=52) @@ | ||
21 | * @link https://packagist.org/packages/austinheap/php-security-txt |
|
22 | * @link https://austinheap.github.io/php-security-txt/classes/AustinHeap.Security.Txt.SecurityTxt.html |
|
23 | */ |
|
24 | trait Encryption |
|
25 | { |
|
26 | ||
27 | /** |
|
28 | * The PGP key file URL. |
|
29 | * |
|
30 | * @var string |
|
31 | */ |
|
32 | protected $encryption = null; |
|
33 | ||
34 | ||
35 | /** |
|
36 | * Set the encryption. |
|
37 | * |
|
38 | * @param string $encryption |
|
39 | * |
|
40 | * @return SecurityTxt |
|
41 | */ |
|
42 | public function setEncryption(string $encryption): SecurityTxt |
|
43 | { |
|
44 | if (!$this->validEncryption($encryption)) { |
|
45 | throw new Exception('Encryption must be a well-formed URL.'); |
|
46 | } |
|
47 | ||
48 | $this->encryption = $encryption; |
|
49 | ||
50 | return $this; |
|
51 | } |
|
52 | ||
53 | /** |
|
54 | * Get the encryption. |
|
55 | * |
|
56 | * @return string |
|
57 | */ |
|
58 | public function getEncryption(): string |
|
59 | { |
|
60 | return $this->encryption; |
|
61 | } |
|
62 | ||
63 | /** |
|
64 | * Determines if encryption is valid. |
|
65 | * |
|
66 | * @param string $encryption |
|
67 | * |
|
68 | * @return bool |
|
69 | */ |
|
70 | public function validEncryption(string $encryption): bool |
|
71 | { |
|
72 | return filter_var($encryption, FILTER_VALIDATE_URL) !== false; |
|
73 | } |
|
74 | ||
75 | } |
|
76 |