@@ -28,8 +28,9 @@ |
||
| 28 | 28 | */ |
| 29 | 29 | public function show() |
| 30 | 30 | { |
| 31 | - if (! config('security-txt.enabled', false)) |
|
| 32 | - abort(404); |
|
| 31 | + if (! config('security-txt.enabled', false)) { |
|
| 32 | + abort(404); |
|
| 33 | + } |
|
| 33 | 34 | |
| 34 | 35 | return \Response::make( |
| 35 | 36 | (new SecurityTxt)->getText(true, true), |
@@ -39,8 +39,9 @@ |
||
| 39 | 39 | __DIR__ . '/config/security-txt.php' => config_path('security-txt.php'), |
| 40 | 40 | ]); |
| 41 | 41 | |
| 42 | - if (! $this->app->routesAreCached()) |
|
| 43 | - require __DIR__ . '/routes/security-txt.php'; |
|
| 42 | + if (! $this->app->routesAreCached()) { |
|
| 43 | + require __DIR__ . '/routes/security-txt.php'; |
|
| 44 | + } |
|
| 44 | 45 | } |
| 45 | 46 | |
| 46 | 47 | /** |
@@ -125,10 +125,11 @@ discard block |
||
| 125 | 125 | 'security-txt.acknowledgement' => ['validator' => 'is_string', 'setter' => 'setAcknowledgement'], |
| 126 | 126 | ]; |
| 127 | 127 | |
| 128 | - foreach ($keys as $key => $mapping) |
|
| 129 | - if (config($key, null) !== null && |
|
| 128 | + foreach ($keys as $key => $mapping) { |
|
| 129 | + if (config($key, null) !== null && |
|
| 130 | 130 | $mapping['validator'](config($key))) |
| 131 | 131 | $this->{$mapping['setter']}(config($key)); |
| 132 | + } |
|
| 132 | 133 | |
| 133 | 134 | return $this; |
| 134 | 135 | } |
@@ -144,51 +145,60 @@ discard block |
||
| 144 | 145 | if ($this->cache) { |
| 145 | 146 | $output = cache($this->cacheKey, null); |
| 146 | 147 | |
| 147 | - if (!is_null($output)) |
|
| 148 | - return $this->setText($output); |
|
| 148 | + if (!is_null($output)) { |
|
| 149 | + return $this->setText($output); |
|
| 150 | + } |
|
| 149 | 151 | } |
| 150 | 152 | |
| 151 | - if ($this->debug) |
|
| 152 | - $time = microtime(true); |
|
| 153 | + if ($this->debug) { |
|
| 154 | + $time = microtime(true); |
|
| 155 | + } |
|
| 153 | 156 | |
| 154 | - if ($reset) |
|
| 155 | - $this->resetLines(); |
|
| 157 | + if ($reset) { |
|
| 158 | + $this->resetLines(); |
|
| 159 | + } |
|
| 156 | 160 | |
| 157 | - if ($this->comments) |
|
| 158 | - $this->addComment('Our security address'); |
|
| 161 | + if ($this->comments) { |
|
| 162 | + $this->addComment('Our security address'); |
|
| 163 | + } |
|
| 159 | 164 | |
| 160 | - if (empty($this->contacts)) |
|
| 161 | - throw new \Exception('One (or more) contacts must be defined.'); |
|
| 165 | + if (empty($this->contacts)) { |
|
| 166 | + throw new \Exception('One (or more) contacts must be defined.'); |
|
| 167 | + } |
|
| 162 | 168 | |
| 163 | - foreach ($this->contacts as $contact) |
|
| 164 | - $this->addLine('Contact: ' . trim($contact)); |
|
| 169 | + foreach ($this->contacts as $contact) { |
|
| 170 | + $this->addLine('Contact: ' . trim($contact)); |
|
| 171 | + } |
|
| 165 | 172 | |
| 166 | 173 | if (!empty($this->encryption)) { |
| 167 | - if ($this->comments) |
|
| 168 | - $this->addSpacer() |
|
| 174 | + if ($this->comments) { |
|
| 175 | + $this->addSpacer() |
|
| 169 | 176 | ->addComment('Our PGP key'); |
| 177 | + } |
|
| 170 | 178 | |
| 171 | 179 | $this->addLine('Encryption: ' . trim($this->encryption)); |
| 172 | 180 | } |
| 173 | 181 | |
| 174 | 182 | if (!empty($this->disclosure)) { |
| 175 | - if ($this->comments) |
|
| 176 | - $this->addSpacer() |
|
| 183 | + if ($this->comments) { |
|
| 184 | + $this->addSpacer() |
|
| 177 | 185 | ->addComment('Our disclosure policy'); |
| 186 | + } |
|
| 178 | 187 | |
| 179 | 188 | $this->addLine('Disclosure: ' . trim(ucfirst($this->disclosure))); |
| 180 | 189 | } |
| 181 | 190 | |
| 182 | 191 | if (!empty($this->acknowledgement)) { |
| 183 | - if ($this->comments) |
|
| 184 | - $this->addSpacer() |
|
| 192 | + if ($this->comments) { |
|
| 193 | + $this->addSpacer() |
|
| 185 | 194 | ->addComment('Our public acknowledgement'); |
| 195 | + } |
|
| 186 | 196 | |
| 187 | 197 | $this->addLine('Acknowledgement: ' . trim($this->acknowledgement)); |
| 188 | 198 | } |
| 189 | 199 | |
| 190 | - if ($this->debug) |
|
| 191 | - $this->addSpacer() |
|
| 200 | + if ($this->debug) { |
|
| 201 | + $this->addSpacer() |
|
| 192 | 202 | ->addComment() |
| 193 | 203 | ->addComment('Generated by https://github.com/austinheap/laravel-security-txt') |
| 194 | 204 | ->addComment('in ' . round((microtime(true) - $time) * 1000, 6) . ' seconds on ' . now() . '.') |
@@ -196,11 +206,13 @@ discard block |
||
| 196 | 206 | ->addComment('Cache is ' . ($this->cache ? 'enabled with key "' . $this->cacheKey . '"' : 'disabled') . '.') |
| 197 | 207 | ->addComment() |
| 198 | 208 | ->addSpacer(); |
| 209 | + } |
|
| 199 | 210 | |
| 200 | 211 | $output = implode(PHP_EOL, $this->lines); |
| 201 | 212 | |
| 202 | - if ($this->cache) |
|
| 203 | - cache([$this->cacheKey => $output], now()->addMinutes($this->cacheTime)); |
|
| 213 | + if ($this->cache) { |
|
| 214 | + cache([$this->cacheKey => $output], now()->addMinutes($this->cacheTime)); |
|
| 215 | + } |
|
| 204 | 216 | |
| 205 | 217 | return $this->setText($output); |
| 206 | 218 | } |
@@ -445,8 +457,9 @@ discard block |
||
| 445 | 457 | */ |
| 446 | 458 | public function getText(bool $generate = false, bool $reset = false): string |
| 447 | 459 | { |
| 448 | - if ($generate) |
|
| 449 | - $this->generate($reset); |
|
| 460 | + if ($generate) { |
|
| 461 | + $this->generate($reset); |
|
| 462 | + } |
|
| 450 | 463 | |
| 451 | 464 | return $this->text === null ? '' : $this->text; |
| 452 | 465 | } |
@@ -493,8 +506,9 @@ discard block |
||
| 493 | 506 | */ |
| 494 | 507 | public function addContacts(array $contacts): SecurityTxt |
| 495 | 508 | { |
| 496 | - foreach ($contacts as $contact) |
|
| 497 | - $this->contact[$contact] = true; |
|
| 509 | + foreach ($contacts as $contact) { |
|
| 510 | + $this->contact[$contact] = true; |
|
| 511 | + } |
|
| 498 | 512 | |
| 499 | 513 | return $this; |
| 500 | 514 | } |
@@ -520,9 +534,10 @@ discard block |
||
| 520 | 534 | */ |
| 521 | 535 | public function removeContacts(array $contacts): SecurityTxt |
| 522 | 536 | { |
| 523 | - foreach ($contacts as $contact) |
|
| 524 | - if (array_key_exists($contact, $this->contacts)) |
|
| 537 | + foreach ($contacts as $contact) { |
|
| 538 | + if (array_key_exists($contact, $this->contacts)) |
|
| 525 | 539 | unset($this->contacts[$contact]); |
| 540 | + } |
|
| 526 | 541 | |
| 527 | 542 | return $this; |
| 528 | 543 | } |
@@ -535,8 +550,9 @@ discard block |
||
| 535 | 550 | */ |
| 536 | 551 | public function setEncryption(string $encryption): SecurityTxt |
| 537 | 552 | { |
| 538 | - if (filter_var($encryption, FILTER_VALIDATE_URL) === false) |
|
| 539 | - throw new \Exception('Encryption must be a well-formed URL.'); |
|
| 553 | + if (filter_var($encryption, FILTER_VALIDATE_URL) === false) { |
|
| 554 | + throw new \Exception('Encryption must be a well-formed URL.'); |
|
| 555 | + } |
|
| 540 | 556 | |
| 541 | 557 | $this->encryption = $encryption; |
| 542 | 558 | |
@@ -561,8 +577,9 @@ discard block |
||
| 561 | 577 | */ |
| 562 | 578 | public function setDisclosure(string $disclosure): SecurityTxt |
| 563 | 579 | { |
| 564 | - if (!in_array(trim(strtolower($disclosure)), ['full', 'partial', 'none'])) |
|
| 565 | - throw new \Exception('Disclosure policy must be either "full", "partial", or "none".'); |
|
| 580 | + if (!in_array(trim(strtolower($disclosure)), ['full', 'partial', 'none'])) { |
|
| 581 | + throw new \Exception('Disclosure policy must be either "full", "partial", or "none".'); |
|
| 582 | + } |
|
| 566 | 583 | |
| 567 | 584 | $this->disclosure = $disclosure; |
| 568 | 585 | |
@@ -587,8 +604,9 @@ discard block |
||
| 587 | 604 | */ |
| 588 | 605 | public function setAcknowledgement(string $acknowledgement): SecurityTxt |
| 589 | 606 | { |
| 590 | - if (filter_var($acknowledgement, FILTER_VALIDATE_URL) === false) |
|
| 591 | - throw new \Exception('Acknowledgement must be a well-formed URL.'); |
|
| 607 | + if (filter_var($acknowledgement, FILTER_VALIDATE_URL) === false) { |
|
| 608 | + throw new \Exception('Acknowledgement must be a well-formed URL.'); |
|
| 609 | + } |
|
| 592 | 610 | |
| 593 | 611 | $this->acknowledgement = $acknowledgement; |
| 594 | 612 | |
@@ -615,8 +633,9 @@ discard block |
||
| 615 | 633 | { |
| 616 | 634 | $comment = trim($comment); |
| 617 | 635 | |
| 618 | - if (!empty($comment)) |
|
| 619 | - $comment = ' ' . $comment; |
|
| 636 | + if (!empty($comment)) { |
|
| 637 | + $comment = ' ' . $comment; |
|
| 638 | + } |
|
| 620 | 639 | |
| 621 | 640 | return $this->addLine('#' . $comment); |
| 622 | 641 | } |