@@ -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 | |
@@ -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 | |