@@ -28,7 +28,7 @@ |
||
28 | 28 | */ |
29 | 29 | public function show() |
30 | 30 | { |
31 | - if (! config('security-txt.enabled', false)) |
|
31 | + if (!config('security-txt.enabled', false)) |
|
32 | 32 | abort(404); |
33 | 33 | |
34 | 34 | return \Response::make( |
@@ -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), |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | * |
27 | 27 | * @var bool |
28 | 28 | */ |
29 | - protected $defer = false; |
|
29 | + protected $defer=false; |
|
30 | 30 | |
31 | 31 | /** |
32 | 32 | * Perform post-registration booting of services. |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | __DIR__ . '/config/security-txt.php' => config_path('security-txt.php'), |
40 | 40 | ]); |
41 | 41 | |
42 | - if (! $this->app->routesAreCached()) |
|
42 | + if (!$this->app->routesAreCached()) |
|
43 | 43 | require __DIR__ . '/routes/security-txt.php'; |
44 | 44 | } |
45 | 45 | |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | __DIR__ . '/config/security-txt.php', 'security-txt' |
55 | 55 | ); |
56 | 56 | |
57 | - $this->app->singleton('securitytxt', function () { |
|
57 | + $this->app->singleton('securitytxt', function() { |
|
58 | 58 | return new SecurityTxt; |
59 | 59 | }); |
60 | 60 | } |
@@ -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 | /** |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | if (!empty($this->encryption)) { |
167 | 167 | if ($this->comments) |
168 | 168 | $this->addSpacer() |
169 | - ->addComment('Our PGP key'); |
|
169 | + ->addComment('Our PGP key'); |
|
170 | 170 | |
171 | 171 | $this->addLine('Encryption: ' . trim($this->encryption)); |
172 | 172 | } |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | if (!empty($this->disclosure)) { |
175 | 175 | if ($this->comments) |
176 | 176 | $this->addSpacer() |
177 | - ->addComment('Our disclosure policy'); |
|
177 | + ->addComment('Our disclosure policy'); |
|
178 | 178 | |
179 | 179 | $this->addLine('Disclosure: ' . trim(ucfirst($this->disclosure))); |
180 | 180 | } |
@@ -182,20 +182,20 @@ discard block |
||
182 | 182 | if (!empty($this->acknowledgement)) { |
183 | 183 | if ($this->comments) |
184 | 184 | $this->addSpacer() |
185 | - ->addComment('Our public acknowledgement'); |
|
185 | + ->addComment('Our public acknowledgement'); |
|
186 | 186 | |
187 | 187 | $this->addLine('Acknowledgement: ' . trim($this->acknowledgement)); |
188 | 188 | } |
189 | 189 | |
190 | 190 | if ($this->debug) |
191 | 191 | $this->addSpacer() |
192 | - ->addComment() |
|
193 | - ->addComment('Generated by https://github.com/austinheap/laravel-security-txt') |
|
194 | - ->addComment('in ' . round((microtime(true) - $time) * 1000, 6) . ' seconds on ' . now() . '.') |
|
195 | - ->addComment() |
|
196 | - ->addComment('Cache is ' . ($this->cache ? 'enabled with key "' . $this->cacheKey . '"' : 'disabled') . '.') |
|
197 | - ->addComment() |
|
198 | - ->addSpacer(); |
|
192 | + ->addComment() |
|
193 | + ->addComment('Generated by https://github.com/austinheap/laravel-security-txt') |
|
194 | + ->addComment('in ' . round((microtime(true) - $time) * 1000, 6) . ' seconds on ' . now() . '.') |
|
195 | + ->addComment() |
|
196 | + ->addComment('Cache is ' . ($this->cache ? 'enabled with key "' . $this->cacheKey . '"' : 'disabled') . '.') |
|
197 | + ->addComment() |
|
198 | + ->addSpacer(); |
|
199 | 199 | |
200 | 200 | $output = implode(PHP_EOL, $this->lines); |
201 | 201 |
@@ -26,84 +26,84 @@ discard block |
||
26 | 26 | * |
27 | 27 | * @var array |
28 | 28 | */ |
29 | - protected $lines = []; |
|
29 | + protected $lines=[ ]; |
|
30 | 30 | |
31 | 31 | /** |
32 | 32 | * Internal text cache. |
33 | 33 | * |
34 | 34 | * @var string |
35 | 35 | */ |
36 | - protected $text = null; |
|
36 | + protected $text=null; |
|
37 | 37 | |
38 | 38 | /** |
39 | 39 | * Enable SecurityTxt. |
40 | 40 | * |
41 | 41 | * @var bool |
42 | 42 | */ |
43 | - protected $enabled = false; |
|
43 | + protected $enabled=false; |
|
44 | 44 | |
45 | 45 | /** |
46 | 46 | * Enable debug output. |
47 | 47 | * |
48 | 48 | * @var bool |
49 | 49 | */ |
50 | - protected $debug = false; |
|
50 | + protected $debug=false; |
|
51 | 51 | |
52 | 52 | /** |
53 | 53 | * Enable built-in cache. |
54 | 54 | * |
55 | 55 | * @var bool |
56 | 56 | */ |
57 | - protected $cache = false; |
|
57 | + protected $cache=false; |
|
58 | 58 | |
59 | 59 | /** |
60 | 60 | * Minutes to cache output. |
61 | 61 | * |
62 | 62 | * @var int |
63 | 63 | */ |
64 | - protected $cacheTime = null; |
|
64 | + protected $cacheTime=null; |
|
65 | 65 | |
66 | 66 | /** |
67 | 67 | * Cache key to use. |
68 | 68 | * |
69 | 69 | * @var string |
70 | 70 | */ |
71 | - protected $cacheKey = 'cache:AustinHeap\Security\Txt\SecurityTxt'; |
|
71 | + protected $cacheKey='cache:AustinHeap\Security\Txt\SecurityTxt'; |
|
72 | 72 | |
73 | 73 | /** |
74 | 74 | * Enable built-in comments. |
75 | 75 | * |
76 | 76 | * @var bool |
77 | 77 | */ |
78 | - protected $comments = true; |
|
78 | + protected $comments=true; |
|
79 | 79 | |
80 | 80 | /** |
81 | 81 | * The security contacts to list. |
82 | 82 | * |
83 | 83 | * @var array |
84 | 84 | */ |
85 | - protected $contacts = []; |
|
85 | + protected $contacts=[ ]; |
|
86 | 86 | |
87 | 87 | /** |
88 | 88 | * The PGP key file URL. |
89 | 89 | * |
90 | 90 | * @var string |
91 | 91 | */ |
92 | - protected $encryption = null; |
|
92 | + protected $encryption=null; |
|
93 | 93 | |
94 | 94 | /** |
95 | 95 | * The disclosure policy. |
96 | 96 | * |
97 | 97 | * @var string |
98 | 98 | */ |
99 | - protected $disclosure = null; |
|
99 | + protected $disclosure=null; |
|
100 | 100 | |
101 | 101 | /** |
102 | 102 | * The acknowledgement URL. |
103 | 103 | * |
104 | 104 | * @var string |
105 | 105 | */ |
106 | - protected $acknowledgement = null; |
|
106 | + protected $acknowledgement=null; |
|
107 | 107 | |
108 | 108 | /** |
109 | 109 | * Create a new SecurityTxt instance. |
@@ -112,23 +112,23 @@ discard block |
||
112 | 112 | */ |
113 | 113 | public function __construct() |
114 | 114 | { |
115 | - $keys = [ |
|
116 | - 'security-txt.enabled' => ['validator' => 'is_bool', 'setter' => 'setEnabled'], |
|
117 | - 'security-txt.debug' => ['validator' => 'is_bool', 'setter' => 'setDebug'], |
|
118 | - 'security-txt.cache' => ['validator' => 'is_bool', 'setter' => 'setCache'], |
|
119 | - 'security-txt.cache-time' => ['validator' => 'is_numeric', 'setter' => 'setCacheTime'], |
|
120 | - 'security-txt.cache-key' => ['validator' => 'is_string', 'setter' => 'setCacheKey'], |
|
121 | - 'security-txt.comments' => ['validator' => 'is_bool', 'setter' => 'setComments'], |
|
122 | - 'security-txt.contacts' => ['validator' => 'is_array', 'setter' => 'setContacts'], |
|
123 | - 'security-txt.encryption' => ['validator' => 'is_string', 'setter' => 'setEncryption'], |
|
124 | - 'security-txt.disclosure' => ['validator' => 'is_string', 'setter' => 'setDisclosure'], |
|
125 | - 'security-txt.acknowledgement' => ['validator' => 'is_string', 'setter' => 'setAcknowledgement'], |
|
115 | + $keys=[ |
|
116 | + 'security-txt.enabled' => [ 'validator' => 'is_bool', 'setter' => 'setEnabled' ], |
|
117 | + 'security-txt.debug' => [ 'validator' => 'is_bool', 'setter' => 'setDebug' ], |
|
118 | + 'security-txt.cache' => [ 'validator' => 'is_bool', 'setter' => 'setCache' ], |
|
119 | + 'security-txt.cache-time' => [ 'validator' => 'is_numeric', 'setter' => 'setCacheTime' ], |
|
120 | + 'security-txt.cache-key' => [ 'validator' => 'is_string', 'setter' => 'setCacheKey' ], |
|
121 | + 'security-txt.comments' => [ 'validator' => 'is_bool', 'setter' => 'setComments' ], |
|
122 | + 'security-txt.contacts' => [ 'validator' => 'is_array', 'setter' => 'setContacts' ], |
|
123 | + 'security-txt.encryption' => [ 'validator' => 'is_string', 'setter' => 'setEncryption' ], |
|
124 | + 'security-txt.disclosure' => [ 'validator' => 'is_string', 'setter' => 'setDisclosure' ], |
|
125 | + 'security-txt.acknowledgement' => [ 'validator' => 'is_string', 'setter' => 'setAcknowledgement' ], |
|
126 | 126 | ]; |
127 | 127 | |
128 | 128 | foreach ($keys as $key => $mapping) |
129 | 129 | if (config($key, null) !== null && |
130 | - $mapping['validator'](config($key))) |
|
131 | - $this->{$mapping['setter']}(config($key)); |
|
130 | + $mapping[ 'validator' ](config($key))) |
|
131 | + $this->{$mapping[ 'setter' ]}(config($key)); |
|
132 | 132 | |
133 | 133 | return $this; |
134 | 134 | } |
@@ -139,17 +139,17 @@ discard block |
||
139 | 139 | * @param bool $reset |
140 | 140 | * @return SecurityTxt |
141 | 141 | */ |
142 | - public function generate(bool $reset = false): SecurityTxt |
|
142 | + public function generate(bool $reset=false): SecurityTxt |
|
143 | 143 | { |
144 | 144 | if ($this->cache) { |
145 | - $output = cache($this->cacheKey, null); |
|
145 | + $output=cache($this->cacheKey, null); |
|
146 | 146 | |
147 | 147 | if (!is_null($output)) |
148 | 148 | return $this->setText($output); |
149 | 149 | } |
150 | 150 | |
151 | 151 | if ($this->debug) |
152 | - $time = microtime(true); |
|
152 | + $time=microtime(true); |
|
153 | 153 | |
154 | 154 | if ($reset) |
155 | 155 | $this->resetLines(); |
@@ -197,10 +197,10 @@ discard block |
||
197 | 197 | ->addComment() |
198 | 198 | ->addSpacer(); |
199 | 199 | |
200 | - $output = implode(PHP_EOL, $this->lines); |
|
200 | + $output=implode(PHP_EOL, $this->lines); |
|
201 | 201 | |
202 | 202 | if ($this->cache) |
203 | - cache([$this->cacheKey => $output], now()->addMinutes($this->cacheTime)); |
|
203 | + cache([ $this->cacheKey => $output ], now()->addMinutes($this->cacheTime)); |
|
204 | 204 | |
205 | 205 | return $this->setText($output); |
206 | 206 | } |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | */ |
234 | 234 | public function setEnabled(bool $enabled): SecurityTxt |
235 | 235 | { |
236 | - $this->enabled = $enabled; |
|
236 | + $this->enabled=$enabled; |
|
237 | 237 | |
238 | 238 | return $this; |
239 | 239 | } |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | */ |
277 | 277 | public function setComments(bool $comments): SecurityTxt |
278 | 278 | { |
279 | - $this->comments = $comments; |
|
279 | + $this->comments=$comments; |
|
280 | 280 | |
281 | 281 | return $this; |
282 | 282 | } |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | */ |
320 | 320 | public function setDebug(bool $debug): SecurityTxt |
321 | 321 | { |
322 | - $this->debug = $debug; |
|
322 | + $this->debug=$debug; |
|
323 | 323 | |
324 | 324 | return $this; |
325 | 325 | } |
@@ -362,7 +362,7 @@ discard block |
||
362 | 362 | */ |
363 | 363 | public function setCache(bool $cache): SecurityTxt |
364 | 364 | { |
365 | - $this->cache = $cache; |
|
365 | + $this->cache=$cache; |
|
366 | 366 | |
367 | 367 | return $this; |
368 | 368 | } |
@@ -385,7 +385,7 @@ discard block |
||
385 | 385 | */ |
386 | 386 | public function setCacheKey(string $cacheKey): SecurityTxt |
387 | 387 | { |
388 | - $this->cacheKey = $cacheKey; |
|
388 | + $this->cacheKey=$cacheKey; |
|
389 | 389 | |
390 | 390 | return $this; |
391 | 391 | } |
@@ -408,7 +408,7 @@ discard block |
||
408 | 408 | */ |
409 | 409 | public function setCacheTime(int $cacheTime): SecurityTxt |
410 | 410 | { |
411 | - $this->cacheTime = $cacheTime; |
|
411 | + $this->cacheTime=$cacheTime; |
|
412 | 412 | |
413 | 413 | return $this; |
414 | 414 | } |
@@ -431,7 +431,7 @@ discard block |
||
431 | 431 | */ |
432 | 432 | public function setText(string $text): SecurityTxt |
433 | 433 | { |
434 | - $this->text = $text; |
|
434 | + $this->text=$text; |
|
435 | 435 | |
436 | 436 | return $this; |
437 | 437 | } |
@@ -443,7 +443,7 @@ discard block |
||
443 | 443 | * @param bool $reset |
444 | 444 | * @return string |
445 | 445 | */ |
446 | - public function getText(bool $generate = false, bool $reset = false): string |
|
446 | + public function getText(bool $generate=false, bool $reset=false): string |
|
447 | 447 | { |
448 | 448 | if ($generate) |
449 | 449 | $this->generate($reset); |
@@ -459,7 +459,7 @@ discard block |
||
459 | 459 | */ |
460 | 460 | public function setContacts(array $contacts): SecurityTxt |
461 | 461 | { |
462 | - $this->contacts = $contacts; |
|
462 | + $this->contacts=$contacts; |
|
463 | 463 | |
464 | 464 | return $this; |
465 | 465 | } |
@@ -471,7 +471,7 @@ discard block |
||
471 | 471 | */ |
472 | 472 | public function getContacts(): array |
473 | 473 | { |
474 | - return is_null($this->contacts) ? [] : $this->contacts; |
|
474 | + return is_null($this->contacts) ? [ ] : $this->contacts; |
|
475 | 475 | } |
476 | 476 | |
477 | 477 | /** |
@@ -482,7 +482,7 @@ discard block |
||
482 | 482 | */ |
483 | 483 | public function addContact(string $contact): SecurityTxt |
484 | 484 | { |
485 | - return $this->addContacts([$contact]); |
|
485 | + return $this->addContacts([ $contact ]); |
|
486 | 486 | } |
487 | 487 | |
488 | 488 | /** |
@@ -494,7 +494,7 @@ discard block |
||
494 | 494 | public function addContacts(array $contacts): SecurityTxt |
495 | 495 | { |
496 | 496 | foreach ($contacts as $contact) |
497 | - $this->contact[$contact] = true; |
|
497 | + $this->contact[ $contact ]=true; |
|
498 | 498 | |
499 | 499 | return $this; |
500 | 500 | } |
@@ -507,7 +507,7 @@ discard block |
||
507 | 507 | */ |
508 | 508 | public function removeContact(string $contact): SecurityTxt |
509 | 509 | { |
510 | - $this->removeContacts([$contact]); |
|
510 | + $this->removeContacts([ $contact ]); |
|
511 | 511 | |
512 | 512 | return $this; |
513 | 513 | } |
@@ -522,7 +522,7 @@ discard block |
||
522 | 522 | { |
523 | 523 | foreach ($contacts as $contact) |
524 | 524 | if (array_key_exists($contact, $this->contacts)) |
525 | - unset($this->contacts[$contact]); |
|
525 | + unset($this->contacts[ $contact ]); |
|
526 | 526 | |
527 | 527 | return $this; |
528 | 528 | } |
@@ -538,7 +538,7 @@ discard block |
||
538 | 538 | if (filter_var($encryption, FILTER_VALIDATE_URL) === false) |
539 | 539 | throw new \Exception('Encryption must be a well-formed URL.'); |
540 | 540 | |
541 | - $this->encryption = $encryption; |
|
541 | + $this->encryption=$encryption; |
|
542 | 542 | |
543 | 543 | return $this; |
544 | 544 | } |
@@ -561,10 +561,10 @@ discard block |
||
561 | 561 | */ |
562 | 562 | public function setDisclosure(string $disclosure): SecurityTxt |
563 | 563 | { |
564 | - if (!in_array(trim(strtolower($disclosure)), ['full', 'partial', 'none'])) |
|
564 | + if (!in_array(trim(strtolower($disclosure)), [ 'full', 'partial', 'none' ])) |
|
565 | 565 | throw new \Exception('Disclosure policy must be either "full", "partial", or "none".'); |
566 | 566 | |
567 | - $this->disclosure = $disclosure; |
|
567 | + $this->disclosure=$disclosure; |
|
568 | 568 | |
569 | 569 | return $this; |
570 | 570 | } |
@@ -590,7 +590,7 @@ discard block |
||
590 | 590 | if (filter_var($acknowledgement, FILTER_VALIDATE_URL) === false) |
591 | 591 | throw new \Exception('Acknowledgement must be a well-formed URL.'); |
592 | 592 | |
593 | - $this->acknowledgement = $acknowledgement; |
|
593 | + $this->acknowledgement=$acknowledgement; |
|
594 | 594 | |
595 | 595 | return $this; |
596 | 596 | } |
@@ -611,12 +611,12 @@ discard block |
||
611 | 611 | * @param string $comment |
612 | 612 | * @return SecurityTxt |
613 | 613 | */ |
614 | - private function addComment(string $comment = ''): SecurityTxt |
|
614 | + private function addComment(string $comment=''): SecurityTxt |
|
615 | 615 | { |
616 | - $comment = trim($comment); |
|
616 | + $comment=trim($comment); |
|
617 | 617 | |
618 | 618 | if (!empty($comment)) |
619 | - $comment = ' ' . $comment; |
|
619 | + $comment=' ' . $comment; |
|
620 | 620 | |
621 | 621 | return $this->addLine('#' . $comment); |
622 | 622 | } |
@@ -639,7 +639,7 @@ discard block |
||
639 | 639 | */ |
640 | 640 | private function addLine(string $line): SecurityTxt |
641 | 641 | { |
642 | - $this->lines[] = $line; |
|
642 | + $this->lines[ ]=$line; |
|
643 | 643 | |
644 | 644 | return $this; |
645 | 645 | } |
@@ -651,7 +651,7 @@ discard block |
||
651 | 651 | */ |
652 | 652 | private function resetLines(): SecurityTxt |
653 | 653 | { |
654 | - $this->lines = []; |
|
654 | + $this->lines=[ ]; |
|
655 | 655 | |
656 | 656 | return $this; |
657 | 657 | } |
@@ -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 | } |
@@ -22,7 +22,7 @@ |
||
22 | 22 | 'comments' => env('SECURITY_TXT_COMMENTS', true), |
23 | 23 | |
24 | 24 | 'contacts' => env('SECURITY_TXT_CONTACT', false) !== false ? |
25 | - [env('SECURITY_TXT_CONTACT')] : null, |
|
25 | + [ env('SECURITY_TXT_CONTACT') ] : null, |
|
26 | 26 | |
27 | 27 | 'encryption' => env('SECURITY_TXT_ENCRYPTION', null), |
28 | 28 |