@@ -7,7 +7,7 @@ |
||
| 7 | 7 | * @version v0.3.0 |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -declare(strict_types=1); |
|
| 10 | +declare(strict_types = 1); |
|
| 11 | 11 | |
| 12 | 12 | namespace AustinHeap\Security\Txt; |
| 13 | 13 | |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | if (!empty($this->encryption)) { |
| 139 | 139 | if ($this->comments) |
| 140 | 140 | $this->spacer() |
| 141 | - ->comment('Our PGP key'); |
|
| 141 | + ->comment('Our PGP key'); |
|
| 142 | 142 | |
| 143 | 143 | $this->line('Encryption: ' . trim($this->encryption)); |
| 144 | 144 | } |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | if (!empty($this->disclosure)) { |
| 147 | 147 | if ($this->comments) |
| 148 | 148 | $this->spacer() |
| 149 | - ->comment('Our disclosure policy'); |
|
| 149 | + ->comment('Our disclosure policy'); |
|
| 150 | 150 | |
| 151 | 151 | $this->line('Disclosure: ' . trim(ucfirst($this->disclosure))); |
| 152 | 152 | } |
@@ -154,24 +154,24 @@ discard block |
||
| 154 | 154 | if (!empty($this->acknowledgement)) { |
| 155 | 155 | if ($this->comments) |
| 156 | 156 | $this->spacer() |
| 157 | - ->comment('Our public acknowledgement'); |
|
| 157 | + ->comment('Our public acknowledgement'); |
|
| 158 | 158 | |
| 159 | 159 | $this->line('Acknowledgement: ' . trim($this->acknowledgement)); |
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | if ($this->debug) |
| 163 | 163 | $this->spacer() |
| 164 | - ->comment() |
|
| 165 | - ->comment( |
|
| 164 | + ->comment() |
|
| 165 | + ->comment( |
|
| 166 | 166 | 'Generated by "' . (defined('LARAVEL_SECURITY_TXT_VERSION') ? 'laravel' : 'php') . '-security-txt"' . |
| 167 | 167 | (defined('LARAVEL_SECURITY_TXT_VERSION') ? ' v' . LARAVEL_SECURITY_TXT_VERSION : (defined('PHP_SECURITY_TXT_VERSION') ? ' v' . PHP_SECURITY_TXT_VERSION : '')) . |
| 168 | 168 | ' (https://github.com/austinheap/' . (defined('LARAVEL_SECURITY_TXT_VERSION') ? 'laravel' : 'php') . '-security-txt' . (defined('LARAVEL_SECURITY_TXT_VERSION') ? '/releases/tag/v' . LARAVEL_SECURITY_TXT_VERSION : (defined('PHP_SECURITY_TXT_VERSION') ? '/releases/tag/v' . PHP_SECURITY_TXT_VERSION : '')) . ')') |
| 169 | - ->comment( |
|
| 169 | + ->comment( |
|
| 170 | 170 | 'using "php-security-txt"' . (defined('PHP_SECURITY_TXT_VERSION') ? ' v' . PHP_SECURITY_TXT_VERSION : '') . |
| 171 | 171 | ' (https://github.com/austinheap/php-security-txt' . (defined('PHP_SECURITY_TXT_VERSION') ? '/releases/tag/v' . PHP_SECURITY_TXT_VERSION : '') . ')') |
| 172 | - ->comment('in ' . round((microtime(true) - $time) * 1000, 6) . ' seconds on ' . now() . '.') |
|
| 173 | - ->comment() |
|
| 174 | - ->spacer(); |
|
| 172 | + ->comment('in ' . round((microtime(true) - $time) * 1000, 6) . ' seconds on ' . now() . '.') |
|
| 173 | + ->comment() |
|
| 174 | + ->spacer(); |
|
| 175 | 175 | |
| 176 | 176 | $output = implode(PHP_EOL, $this->lines); |
| 177 | 177 | |
@@ -7,7 +7,7 @@ discard block |
||
| 7 | 7 | * @version v0.3.0 |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -declare(strict_types=1); |
|
| 10 | +declare(strict_types = 1); |
|
| 11 | 11 | |
| 12 | 12 | namespace AustinHeap\Security\Txt; |
| 13 | 13 | |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | * |
| 27 | 27 | * @var array |
| 28 | 28 | */ |
| 29 | - private $lines = []; |
|
| 29 | + private $lines = []; |
|
| 30 | 30 | |
| 31 | 31 | /** |
| 32 | 32 | * Create a new Writer instance. |
@@ -49,9 +49,9 @@ discard block |
||
| 49 | 49 | $comment = trim($comment); |
| 50 | 50 | |
| 51 | 51 | if (!empty($comment)) |
| 52 | - $comment = ' ' . $comment; |
|
| 52 | + $comment = ' '.$comment; |
|
| 53 | 53 | |
| 54 | - return $this->line(trim('#' . $comment)); |
|
| 54 | + return $this->line(trim('#'.$comment)); |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | /** |
@@ -133,14 +133,14 @@ discard block |
||
| 133 | 133 | throw new \Exception('One (or more) contacts must be defined.'); |
| 134 | 134 | |
| 135 | 135 | foreach ($this->contacts as $contact) |
| 136 | - $this->line('Contact: ' . trim($contact)); |
|
| 136 | + $this->line('Contact: '.trim($contact)); |
|
| 137 | 137 | |
| 138 | 138 | if (!empty($this->encryption)) { |
| 139 | 139 | if ($this->comments) |
| 140 | 140 | $this->spacer() |
| 141 | 141 | ->comment('Our PGP key'); |
| 142 | 142 | |
| 143 | - $this->line('Encryption: ' . trim($this->encryption)); |
|
| 143 | + $this->line('Encryption: '.trim($this->encryption)); |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | if (!empty($this->disclosure)) { |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | $this->spacer() |
| 149 | 149 | ->comment('Our disclosure policy'); |
| 150 | 150 | |
| 151 | - $this->line('Disclosure: ' . trim(ucfirst($this->disclosure))); |
|
| 151 | + $this->line('Disclosure: '.trim(ucfirst($this->disclosure))); |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | if (!empty($this->acknowledgement)) { |
@@ -156,20 +156,20 @@ discard block |
||
| 156 | 156 | $this->spacer() |
| 157 | 157 | ->comment('Our public acknowledgement'); |
| 158 | 158 | |
| 159 | - $this->line('Acknowledgement: ' . trim($this->acknowledgement)); |
|
| 159 | + $this->line('Acknowledgement: '.trim($this->acknowledgement)); |
|
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | if ($this->debug) |
| 163 | 163 | $this->spacer() |
| 164 | 164 | ->comment() |
| 165 | 165 | ->comment( |
| 166 | - 'Generated by "' . (defined('LARAVEL_SECURITY_TXT_VERSION') ? 'laravel' : 'php') . '-security-txt"' . |
|
| 167 | - (defined('LARAVEL_SECURITY_TXT_VERSION') ? ' v' . LARAVEL_SECURITY_TXT_VERSION : (defined('PHP_SECURITY_TXT_VERSION') ? ' v' . PHP_SECURITY_TXT_VERSION : '')) . |
|
| 168 | - ' (https://github.com/austinheap/' . (defined('LARAVEL_SECURITY_TXT_VERSION') ? 'laravel' : 'php') . '-security-txt' . (defined('LARAVEL_SECURITY_TXT_VERSION') ? '/releases/tag/v' . LARAVEL_SECURITY_TXT_VERSION : (defined('PHP_SECURITY_TXT_VERSION') ? '/releases/tag/v' . PHP_SECURITY_TXT_VERSION : '')) . ')') |
|
| 166 | + 'Generated by "'.(defined('LARAVEL_SECURITY_TXT_VERSION') ? 'laravel' : 'php').'-security-txt"'. |
|
| 167 | + (defined('LARAVEL_SECURITY_TXT_VERSION') ? ' v'.LARAVEL_SECURITY_TXT_VERSION : (defined('PHP_SECURITY_TXT_VERSION') ? ' v'.PHP_SECURITY_TXT_VERSION : '')). |
|
| 168 | + ' (https://github.com/austinheap/'.(defined('LARAVEL_SECURITY_TXT_VERSION') ? 'laravel' : 'php').'-security-txt'.(defined('LARAVEL_SECURITY_TXT_VERSION') ? '/releases/tag/v'.LARAVEL_SECURITY_TXT_VERSION : (defined('PHP_SECURITY_TXT_VERSION') ? '/releases/tag/v'.PHP_SECURITY_TXT_VERSION : '')).')') |
|
| 169 | 169 | ->comment( |
| 170 | - 'using "php-security-txt"' . (defined('PHP_SECURITY_TXT_VERSION') ? ' v' . PHP_SECURITY_TXT_VERSION : '') . |
|
| 171 | - ' (https://github.com/austinheap/php-security-txt' . (defined('PHP_SECURITY_TXT_VERSION') ? '/releases/tag/v' . PHP_SECURITY_TXT_VERSION : '') . ')') |
|
| 172 | - ->comment('in ' . round((microtime(true) - $time) * 1000, 6) . ' seconds on ' . now() . '.') |
|
| 170 | + 'using "php-security-txt"'.(defined('PHP_SECURITY_TXT_VERSION') ? ' v'.PHP_SECURITY_TXT_VERSION : ''). |
|
| 171 | + ' (https://github.com/austinheap/php-security-txt'.(defined('PHP_SECURITY_TXT_VERSION') ? '/releases/tag/v'.PHP_SECURITY_TXT_VERSION : '').')') |
|
| 172 | + ->comment('in '.round((microtime(true) - $time) * 1000, 6).' seconds on '.now().'.') |
|
| 173 | 173 | ->comment() |
| 174 | 174 | ->spacer(); |
| 175 | 175 | |
@@ -48,8 +48,9 @@ discard block |
||
| 48 | 48 | { |
| 49 | 49 | $comment = trim($comment); |
| 50 | 50 | |
| 51 | - if (!empty($comment)) |
|
| 52 | - $comment = ' ' . $comment; |
|
| 51 | + if (!empty($comment)) { |
|
| 52 | + $comment = ' ' . $comment; |
|
| 53 | + } |
|
| 53 | 54 | |
| 54 | 55 | return $this->line(trim('#' . $comment)); |
| 55 | 56 | } |
@@ -71,8 +72,9 @@ discard block |
||
| 71 | 72 | */ |
| 72 | 73 | public function spacers($count = 1): Writer |
| 73 | 74 | { |
| 74 | - for ($x = 0; $x < $count; $x++) |
|
| 75 | - $this->spacer(); |
|
| 75 | + for ($x = 0; $x < $count; $x++) { |
|
| 76 | + $this->spacer(); |
|
| 77 | + } |
|
| 76 | 78 | |
| 77 | 79 | return $this; |
| 78 | 80 | } |
@@ -98,8 +100,9 @@ discard block |
||
| 98 | 100 | */ |
| 99 | 101 | public function lines(array $lines): Writer |
| 100 | 102 | { |
| 101 | - foreach ($lines as $line) |
|
| 102 | - $this->line($line); |
|
| 103 | + foreach ($lines as $line) { |
|
| 104 | + $this->line($line); |
|
| 105 | + } |
|
| 103 | 106 | |
| 104 | 107 | return $this; |
| 105 | 108 | } |
@@ -123,44 +126,51 @@ discard block |
||
| 123 | 126 | */ |
| 124 | 127 | public function generate(): Writer |
| 125 | 128 | { |
| 126 | - if ($this->debug) |
|
| 127 | - $time = microtime(true); |
|
| 129 | + if ($this->debug) { |
|
| 130 | + $time = microtime(true); |
|
| 131 | + } |
|
| 128 | 132 | |
| 129 | - if ($this->comments) |
|
| 130 | - $this->comment('Our security address'); |
|
| 133 | + if ($this->comments) { |
|
| 134 | + $this->comment('Our security address'); |
|
| 135 | + } |
|
| 131 | 136 | |
| 132 | - if (empty($this->contacts)) |
|
| 133 | - throw new \Exception('One (or more) contacts must be defined.'); |
|
| 137 | + if (empty($this->contacts)) { |
|
| 138 | + throw new \Exception('One (or more) contacts must be defined.'); |
|
| 139 | + } |
|
| 134 | 140 | |
| 135 | - foreach ($this->contacts as $contact) |
|
| 136 | - $this->line('Contact: ' . trim($contact)); |
|
| 141 | + foreach ($this->contacts as $contact) { |
|
| 142 | + $this->line('Contact: ' . trim($contact)); |
|
| 143 | + } |
|
| 137 | 144 | |
| 138 | 145 | if (!empty($this->encryption)) { |
| 139 | - if ($this->comments) |
|
| 140 | - $this->spacer() |
|
| 146 | + if ($this->comments) { |
|
| 147 | + $this->spacer() |
|
| 141 | 148 | ->comment('Our PGP key'); |
| 149 | + } |
|
| 142 | 150 | |
| 143 | 151 | $this->line('Encryption: ' . trim($this->encryption)); |
| 144 | 152 | } |
| 145 | 153 | |
| 146 | 154 | if (!empty($this->disclosure)) { |
| 147 | - if ($this->comments) |
|
| 148 | - $this->spacer() |
|
| 155 | + if ($this->comments) { |
|
| 156 | + $this->spacer() |
|
| 149 | 157 | ->comment('Our disclosure policy'); |
| 158 | + } |
|
| 150 | 159 | |
| 151 | 160 | $this->line('Disclosure: ' . trim(ucfirst($this->disclosure))); |
| 152 | 161 | } |
| 153 | 162 | |
| 154 | 163 | if (!empty($this->acknowledgement)) { |
| 155 | - if ($this->comments) |
|
| 156 | - $this->spacer() |
|
| 164 | + if ($this->comments) { |
|
| 165 | + $this->spacer() |
|
| 157 | 166 | ->comment('Our public acknowledgement'); |
| 167 | + } |
|
| 158 | 168 | |
| 159 | 169 | $this->line('Acknowledgement: ' . trim($this->acknowledgement)); |
| 160 | 170 | } |
| 161 | 171 | |
| 162 | - if ($this->debug) |
|
| 163 | - $this->spacer() |
|
| 172 | + if ($this->debug) { |
|
| 173 | + $this->spacer() |
|
| 164 | 174 | ->comment() |
| 165 | 175 | ->comment( |
| 166 | 176 | 'Generated by "' . (defined('LARAVEL_SECURITY_TXT_VERSION') ? 'laravel' : 'php') . '-security-txt"' . |
@@ -172,6 +182,7 @@ discard block |
||
| 172 | 182 | ->comment('in ' . round((microtime(true) - $time) * 1000, 6) . ' seconds on ' . now() . '.') |
| 173 | 183 | ->comment() |
| 174 | 184 | ->spacer(); |
| 185 | + } |
|
| 175 | 186 | |
| 176 | 187 | $output = implode(PHP_EOL, $this->lines); |
| 177 | 188 | |
@@ -7,7 +7,7 @@ discard block |
||
| 7 | 7 | * @version v0.3.0 |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -declare(strict_types=1); |
|
| 10 | +declare(strict_types = 1); |
|
| 11 | 11 | |
| 12 | 12 | namespace AustinHeap\Security\Txt; |
| 13 | 13 | |
@@ -26,77 +26,77 @@ discard block |
||
| 26 | 26 | * |
| 27 | 27 | * @var string |
| 28 | 28 | */ |
| 29 | - const VERSION = '0.3.0'; |
|
| 29 | + const VERSION = '0.3.0'; |
|
| 30 | 30 | |
| 31 | 31 | /** |
| 32 | 32 | * Internal parent object. |
| 33 | 33 | * |
| 34 | 34 | * @var \AustinHeap\Security\Txt\Writer|\AustinHeap\Security\Txt\Reader |
| 35 | 35 | */ |
| 36 | - private $parent = null; |
|
| 36 | + private $parent = null; |
|
| 37 | 37 | |
| 38 | 38 | /** |
| 39 | 39 | * Internal Writer object. |
| 40 | 40 | * |
| 41 | 41 | * @var \AustinHeap\Security\Txt\Writer |
| 42 | 42 | */ |
| 43 | - protected $writer = null; |
|
| 43 | + protected $writer = null; |
|
| 44 | 44 | |
| 45 | 45 | /** |
| 46 | 46 | * Internal Reader object. |
| 47 | 47 | * |
| 48 | 48 | * @var \AustinHeap\Security\Txt\Reader |
| 49 | 49 | */ |
| 50 | - protected $reader = null; |
|
| 50 | + protected $reader = null; |
|
| 51 | 51 | |
| 52 | 52 | /** |
| 53 | 53 | * Internal text cache. |
| 54 | 54 | * |
| 55 | 55 | * @var string |
| 56 | 56 | */ |
| 57 | - protected $text = null; |
|
| 57 | + protected $text = null; |
|
| 58 | 58 | |
| 59 | 59 | /** |
| 60 | 60 | * Enable debug output. |
| 61 | 61 | * |
| 62 | 62 | * @var bool |
| 63 | 63 | */ |
| 64 | - protected $debug = false; |
|
| 64 | + protected $debug = false; |
|
| 65 | 65 | |
| 66 | 66 | /** |
| 67 | 67 | * Enable built-in comments. |
| 68 | 68 | * |
| 69 | 69 | * @var bool |
| 70 | 70 | */ |
| 71 | - protected $comments = true; |
|
| 71 | + protected $comments = true; |
|
| 72 | 72 | |
| 73 | 73 | /** |
| 74 | 74 | * The security contact(s). |
| 75 | 75 | * |
| 76 | 76 | * @var array |
| 77 | 77 | */ |
| 78 | - protected $contacts = []; |
|
| 78 | + protected $contacts = []; |
|
| 79 | 79 | |
| 80 | 80 | /** |
| 81 | 81 | * The PGP key file URL. |
| 82 | 82 | * |
| 83 | 83 | * @var string |
| 84 | 84 | */ |
| 85 | - protected $encryption = null; |
|
| 85 | + protected $encryption = null; |
|
| 86 | 86 | |
| 87 | 87 | /** |
| 88 | 88 | * The disclosure policy. |
| 89 | 89 | * |
| 90 | 90 | * @var string |
| 91 | 91 | */ |
| 92 | - protected $disclosure = null; |
|
| 92 | + protected $disclosure = null; |
|
| 93 | 93 | |
| 94 | 94 | /** |
| 95 | 95 | * The acknowledgement URL. |
| 96 | 96 | * |
| 97 | 97 | * @var string |
| 98 | 98 | */ |
| 99 | - protected $acknowledgement = null; |
|
| 99 | + protected $acknowledgement = null; |
|
| 100 | 100 | |
| 101 | 101 | /** |
| 102 | 102 | * Create a new SecurityTxt instance. |
@@ -105,8 +105,9 @@ discard block |
||
| 105 | 105 | */ |
| 106 | 106 | public function __construct(&$parent = null) |
| 107 | 107 | { |
| 108 | - if (!defined('PHP_SECURITY_TXT_VERSION')) |
|
| 109 | - define('PHP_SECURITY_TXT_VERSION', self::VERSION); |
|
| 108 | + if (!defined('PHP_SECURITY_TXT_VERSION')) { |
|
| 109 | + define('PHP_SECURITY_TXT_VERSION', self::VERSION); |
|
| 110 | + } |
|
| 110 | 111 | |
| 111 | 112 | $this->parent = $parent; |
| 112 | 113 | |
@@ -264,8 +265,9 @@ discard block |
||
| 264 | 265 | */ |
| 265 | 266 | public function addContacts(array $contacts): SecurityTxt |
| 266 | 267 | { |
| 267 | - foreach ($contacts as $contact) |
|
| 268 | - $this->contacts[$contact] = true; |
|
| 268 | + foreach ($contacts as $contact) { |
|
| 269 | + $this->contacts[$contact] = true; |
|
| 270 | + } |
|
| 269 | 271 | |
| 270 | 272 | return $this; |
| 271 | 273 | } |
@@ -291,9 +293,10 @@ discard block |
||
| 291 | 293 | */ |
| 292 | 294 | public function removeContacts(array $contacts): SecurityTxt |
| 293 | 295 | { |
| 294 | - foreach ($contacts as $contact) |
|
| 295 | - if (array_key_exists($contact, $this->contacts)) |
|
| 296 | + foreach ($contacts as $contact) { |
|
| 297 | + if (array_key_exists($contact, $this->contacts)) |
|
| 296 | 298 | unset($this->contacts[$contact]); |
| 299 | + } |
|
| 297 | 300 | |
| 298 | 301 | return $this; |
| 299 | 302 | } |
@@ -306,8 +309,9 @@ discard block |
||
| 306 | 309 | */ |
| 307 | 310 | public function setEncryption(string $encryption): SecurityTxt |
| 308 | 311 | { |
| 309 | - if (filter_var($encryption, FILTER_VALIDATE_URL) === false) |
|
| 310 | - throw new \Exception('Encryption must be a well-formed URL.'); |
|
| 312 | + if (filter_var($encryption, FILTER_VALIDATE_URL) === false) { |
|
| 313 | + throw new \Exception('Encryption must be a well-formed URL.'); |
|
| 314 | + } |
|
| 311 | 315 | |
| 312 | 316 | $this->encryption = $encryption; |
| 313 | 317 | |
@@ -332,8 +336,9 @@ discard block |
||
| 332 | 336 | */ |
| 333 | 337 | public function setDisclosure(string $disclosure): SecurityTxt |
| 334 | 338 | { |
| 335 | - if (!in_array(trim(strtolower($disclosure)), ['full', 'partial', 'none'])) |
|
| 336 | - throw new \Exception('Disclosure policy must be either "full", "partial", or "none".'); |
|
| 339 | + if (!in_array(trim(strtolower($disclosure)), ['full', 'partial', 'none'])) { |
|
| 340 | + throw new \Exception('Disclosure policy must be either "full", "partial", or "none".'); |
|
| 341 | + } |
|
| 337 | 342 | |
| 338 | 343 | $this->disclosure = $disclosure; |
| 339 | 344 | |
@@ -358,8 +363,9 @@ discard block |
||
| 358 | 363 | */ |
| 359 | 364 | public function setAcknowledgement(string $acknowledgement): SecurityTxt |
| 360 | 365 | { |
| 361 | - if (filter_var($acknowledgement, FILTER_VALIDATE_URL) === false) |
|
| 362 | - throw new \Exception('Acknowledgement must be a well-formed URL.'); |
|
| 366 | + if (filter_var($acknowledgement, FILTER_VALIDATE_URL) === false) { |
|
| 367 | + throw new \Exception('Acknowledgement must be a well-formed URL.'); |
|
| 368 | + } |
|
| 363 | 369 | |
| 364 | 370 | $this->acknowledgement = $acknowledgement; |
| 365 | 371 | |