1 | <?php |
||
2 | /** |
||
3 | * src/Directives/Acknowledgement.php |
||
4 | * |
||
5 | * @package php-security-txt |
||
6 | * @author Austin Heap <[email protected]> |
||
7 | * @version v0.4.0 |
||
8 | */ |
||
9 | |||
10 | declare(strict_types = 1); |
||
11 | |||
12 | namespace AustinHeap\Security\Txt\Directives; |
||
13 | |||
14 | use AustinHeap\Security\Txt\SecurityTxt; |
||
15 | use Exception; |
||
16 | |||
17 | /** |
||
18 | * Acknowledgement |
||
19 | * |
||
20 | * @link https://github.com/austinheap/php-security-txt |
||
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 | * @link https://securitytext.org/ |
||
24 | */ |
||
25 | trait Acknowledgement |
||
26 | { |
||
27 | |||
28 | /** |
||
29 | * The acknowledgement URL. |
||
30 | * |
||
31 | * @var string |
||
32 | */ |
||
33 | protected $acknowledgement = null; |
||
34 | |||
35 | /** |
||
36 | * Set the acknowledgement URL. |
||
37 | * |
||
38 | * @param string $acknowledgement |
||
39 | * |
||
40 | * @return SecurityTxt |
||
41 | */ |
||
42 | 3 | public function setAcknowledgement(string $acknowledgement): SecurityTxt |
|
43 | { |
||
44 | 3 | if (filter_var($acknowledgement, FILTER_VALIDATE_URL) === false) { |
|
45 | 1 | throw new Exception('Acknowledgement must be a well-formed URL.'); |
|
46 | } |
||
47 | |||
48 | 2 | $this->acknowledgement = $acknowledgement; |
|
49 | |||
50 | 2 | return $this; |
|
0 ignored issues
–
show
Bug
Best Practice
introduced
by
![]() |
|||
51 | } |
||
52 | |||
53 | /** |
||
54 | * Get the acknowledgement URL. |
||
55 | * |
||
56 | * @return string |
||
57 | */ |
||
58 | 1 | public function getAcknowledgement(): string |
|
59 | { |
||
60 | 1 | return $this->acknowledgement; |
|
61 | } |
||
62 | } |
||
63 |