@@ -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 | } |
@@ -145,53 +146,62 @@ discard block |
||
145 | 146 | $output = cache($this->cacheKey, null); |
146 | 147 | |
147 | 148 | if (!is_null($output) && |
148 | - is_string($output)) |
|
149 | - return $this->setText($output); |
|
149 | + is_string($output)) { |
|
150 | + return $this->setText($output); |
|
151 | + } |
|
150 | 152 | |
151 | 153 | unset($output); |
152 | 154 | } |
153 | 155 | |
154 | - if ($this->debug) |
|
155 | - $time = microtime(true); |
|
156 | + if ($this->debug) { |
|
157 | + $time = microtime(true); |
|
158 | + } |
|
156 | 159 | |
157 | - if ($reset) |
|
158 | - $this->resetLines(); |
|
160 | + if ($reset) { |
|
161 | + $this->resetLines(); |
|
162 | + } |
|
159 | 163 | |
160 | - if ($this->comments) |
|
161 | - $this->addComment('Our security address'); |
|
164 | + if ($this->comments) { |
|
165 | + $this->addComment('Our security address'); |
|
166 | + } |
|
162 | 167 | |
163 | - if (empty($this->contacts)) |
|
164 | - throw new \Exception('One (or more) contacts must be defined.'); |
|
168 | + if (empty($this->contacts)) { |
|
169 | + throw new \Exception('One (or more) contacts must be defined.'); |
|
170 | + } |
|
165 | 171 | |
166 | - foreach ($this->contacts as $contact) |
|
167 | - $this->addLine('Contact: ' . trim($contact)); |
|
172 | + foreach ($this->contacts as $contact) { |
|
173 | + $this->addLine('Contact: ' . trim($contact)); |
|
174 | + } |
|
168 | 175 | |
169 | 176 | if (!empty($this->encryption)) { |
170 | - if ($this->comments) |
|
171 | - $this->addSpacer() |
|
177 | + if ($this->comments) { |
|
178 | + $this->addSpacer() |
|
172 | 179 | ->addComment('Our PGP key'); |
180 | + } |
|
173 | 181 | |
174 | 182 | $this->addLine('Encryption: ' . trim($this->encryption)); |
175 | 183 | } |
176 | 184 | |
177 | 185 | if (!empty($this->disclosure)) { |
178 | - if ($this->comments) |
|
179 | - $this->addSpacer() |
|
186 | + if ($this->comments) { |
|
187 | + $this->addSpacer() |
|
180 | 188 | ->addComment('Our disclosure policy'); |
189 | + } |
|
181 | 190 | |
182 | 191 | $this->addLine('Disclosure: ' . trim(ucfirst($this->disclosure))); |
183 | 192 | } |
184 | 193 | |
185 | 194 | if (!empty($this->acknowledgement)) { |
186 | - if ($this->comments) |
|
187 | - $this->addSpacer() |
|
195 | + if ($this->comments) { |
|
196 | + $this->addSpacer() |
|
188 | 197 | ->addComment('Our public acknowledgement'); |
198 | + } |
|
189 | 199 | |
190 | 200 | $this->addLine('Acknowledgement: ' . trim($this->acknowledgement)); |
191 | 201 | } |
192 | 202 | |
193 | - if ($this->debug) |
|
194 | - $this->addSpacer() |
|
203 | + if ($this->debug) { |
|
204 | + $this->addSpacer() |
|
195 | 205 | ->addComment() |
196 | 206 | ->addComment('Generated by https://github.com/austinheap/laravel-security-txt') |
197 | 207 | ->addComment('in ' . round((microtime(true) - $time) * 1000, 6) . ' seconds on ' . now() . '.') |
@@ -199,11 +209,13 @@ discard block |
||
199 | 209 | ->addComment('Cache is ' . ($this->cache ? 'enabled with key "' . $this->cacheKey . '"' : 'disabled') . '.') |
200 | 210 | ->addComment() |
201 | 211 | ->addSpacer(); |
212 | + } |
|
202 | 213 | |
203 | 214 | $output = implode(PHP_EOL, $this->lines); |
204 | 215 | |
205 | - if ($this->cache) |
|
206 | - cache([$this->cacheKey => $output], now()->addMinutes($this->cacheTime)); |
|
216 | + if ($this->cache) { |
|
217 | + cache([$this->cacheKey => $output], now()->addMinutes($this->cacheTime)); |
|
218 | + } |
|
207 | 219 | |
208 | 220 | return $this->setText($output); |
209 | 221 | } |
@@ -448,8 +460,9 @@ discard block |
||
448 | 460 | */ |
449 | 461 | public function getText(bool $generate = false, bool $reset = false): string |
450 | 462 | { |
451 | - if ($generate) |
|
452 | - $this->generate($reset); |
|
463 | + if ($generate) { |
|
464 | + $this->generate($reset); |
|
465 | + } |
|
453 | 466 | |
454 | 467 | return $this->text === null ? '' : $this->text; |
455 | 468 | } |
@@ -496,8 +509,9 @@ discard block |
||
496 | 509 | */ |
497 | 510 | public function addContacts(array $contacts): SecurityTxt |
498 | 511 | { |
499 | - foreach ($contacts as $contact) |
|
500 | - $this->contacts[$contact] = true; |
|
512 | + foreach ($contacts as $contact) { |
|
513 | + $this->contacts[$contact] = true; |
|
514 | + } |
|
501 | 515 | |
502 | 516 | return $this; |
503 | 517 | } |
@@ -523,9 +537,10 @@ discard block |
||
523 | 537 | */ |
524 | 538 | public function removeContacts(array $contacts): SecurityTxt |
525 | 539 | { |
526 | - foreach ($contacts as $contact) |
|
527 | - if (array_key_exists($contact, $this->contacts)) |
|
540 | + foreach ($contacts as $contact) { |
|
541 | + if (array_key_exists($contact, $this->contacts)) |
|
528 | 542 | unset($this->contacts[$contact]); |
543 | + } |
|
529 | 544 | |
530 | 545 | return $this; |
531 | 546 | } |
@@ -538,8 +553,9 @@ discard block |
||
538 | 553 | */ |
539 | 554 | public function setEncryption(string $encryption): SecurityTxt |
540 | 555 | { |
541 | - if (filter_var($encryption, FILTER_VALIDATE_URL) === false) |
|
542 | - throw new \Exception('Encryption must be a well-formed URL.'); |
|
556 | + if (filter_var($encryption, FILTER_VALIDATE_URL) === false) { |
|
557 | + throw new \Exception('Encryption must be a well-formed URL.'); |
|
558 | + } |
|
543 | 559 | |
544 | 560 | $this->encryption = $encryption; |
545 | 561 | |
@@ -564,8 +580,9 @@ discard block |
||
564 | 580 | */ |
565 | 581 | public function setDisclosure(string $disclosure): SecurityTxt |
566 | 582 | { |
567 | - if (!in_array(trim(strtolower($disclosure)), ['full', 'partial', 'none'])) |
|
568 | - throw new \Exception('Disclosure policy must be either "full", "partial", or "none".'); |
|
583 | + if (!in_array(trim(strtolower($disclosure)), ['full', 'partial', 'none'])) { |
|
584 | + throw new \Exception('Disclosure policy must be either "full", "partial", or "none".'); |
|
585 | + } |
|
569 | 586 | |
570 | 587 | $this->disclosure = $disclosure; |
571 | 588 | |
@@ -590,8 +607,9 @@ discard block |
||
590 | 607 | */ |
591 | 608 | public function setAcknowledgement(string $acknowledgement): SecurityTxt |
592 | 609 | { |
593 | - if (filter_var($acknowledgement, FILTER_VALIDATE_URL) === false) |
|
594 | - throw new \Exception('Acknowledgement must be a well-formed URL.'); |
|
610 | + if (filter_var($acknowledgement, FILTER_VALIDATE_URL) === false) { |
|
611 | + throw new \Exception('Acknowledgement must be a well-formed URL.'); |
|
612 | + } |
|
595 | 613 | |
596 | 614 | $this->acknowledgement = $acknowledgement; |
597 | 615 | |
@@ -618,8 +636,9 @@ discard block |
||
618 | 636 | { |
619 | 637 | $comment = trim($comment); |
620 | 638 | |
621 | - if (!empty($comment)) |
|
622 | - $comment = ' ' . $comment; |
|
639 | + if (!empty($comment)) { |
|
640 | + $comment = ' ' . $comment; |
|
641 | + } |
|
623 | 642 | |
624 | 643 | return $this->addLine('#' . $comment); |
625 | 644 | } |
@@ -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 | } |
@@ -145,53 +146,62 @@ discard block |
||
145 | 146 | $output = cache($this->cacheKey, null); |
146 | 147 | |
147 | 148 | if (!is_null($output) && |
148 | - is_string($output)) |
|
149 | - return $this->setText($output); |
|
149 | + is_string($output)) { |
|
150 | + return $this->setText($output); |
|
151 | + } |
|
150 | 152 | |
151 | 153 | unset($output); |
152 | 154 | } |
153 | 155 | |
154 | - if ($this->debug) |
|
155 | - $time = microtime(true); |
|
156 | + if ($this->debug) { |
|
157 | + $time = microtime(true); |
|
158 | + } |
|
156 | 159 | |
157 | - if ($reset) |
|
158 | - $this->resetLines(); |
|
160 | + if ($reset) { |
|
161 | + $this->resetLines(); |
|
162 | + } |
|
159 | 163 | |
160 | - if ($this->comments) |
|
161 | - $this->addComment('Our security address'); |
|
164 | + if ($this->comments) { |
|
165 | + $this->addComment('Our security address'); |
|
166 | + } |
|
162 | 167 | |
163 | - if (empty($this->contacts)) |
|
164 | - throw new \Exception('One (or more) contacts must be defined.'); |
|
168 | + if (empty($this->contacts)) { |
|
169 | + throw new \Exception('One (or more) contacts must be defined.'); |
|
170 | + } |
|
165 | 171 | |
166 | - foreach ($this->contacts as $contact) |
|
167 | - $this->addLine('Contact: ' . trim($contact)); |
|
172 | + foreach ($this->contacts as $contact) { |
|
173 | + $this->addLine('Contact: ' . trim($contact)); |
|
174 | + } |
|
168 | 175 | |
169 | 176 | if (!empty($this->encryption)) { |
170 | - if ($this->comments) |
|
171 | - $this->addSpacer() |
|
177 | + if ($this->comments) { |
|
178 | + $this->addSpacer() |
|
172 | 179 | ->addComment('Our PGP key'); |
180 | + } |
|
173 | 181 | |
174 | 182 | $this->addLine('Encryption: ' . trim($this->encryption)); |
175 | 183 | } |
176 | 184 | |
177 | 185 | if (!empty($this->disclosure)) { |
178 | - if ($this->comments) |
|
179 | - $this->addSpacer() |
|
186 | + if ($this->comments) { |
|
187 | + $this->addSpacer() |
|
180 | 188 | ->addComment('Our disclosure policy'); |
189 | + } |
|
181 | 190 | |
182 | 191 | $this->addLine('Disclosure: ' . trim(ucfirst($this->disclosure))); |
183 | 192 | } |
184 | 193 | |
185 | 194 | if (!empty($this->acknowledgement)) { |
186 | - if ($this->comments) |
|
187 | - $this->addSpacer() |
|
195 | + if ($this->comments) { |
|
196 | + $this->addSpacer() |
|
188 | 197 | ->addComment('Our public acknowledgement'); |
198 | + } |
|
189 | 199 | |
190 | 200 | $this->addLine('Acknowledgement: ' . trim($this->acknowledgement)); |
191 | 201 | } |
192 | 202 | |
193 | - if ($this->debug) |
|
194 | - $this->addSpacer() |
|
203 | + if ($this->debug) { |
|
204 | + $this->addSpacer() |
|
195 | 205 | ->addComment() |
196 | 206 | ->addComment('Generated by https://github.com/austinheap/laravel-security-txt') |
197 | 207 | ->addComment('in ' . round((microtime(true) - $time) * 1000, 6) . ' seconds on ' . now() . '.') |
@@ -199,11 +209,13 @@ discard block |
||
199 | 209 | ->addComment('Cache is ' . ($this->cache ? 'enabled with key "' . $this->cacheKey . '"' : 'disabled') . '.') |
200 | 210 | ->addComment() |
201 | 211 | ->addSpacer(); |
212 | + } |
|
202 | 213 | |
203 | 214 | $output = implode(PHP_EOL, $this->lines); |
204 | 215 | |
205 | - if ($this->cache) |
|
206 | - cache([$this->cacheKey => $output], now()->addMinutes($this->cacheTime)); |
|
216 | + if ($this->cache) { |
|
217 | + cache([$this->cacheKey => $output], now()->addMinutes($this->cacheTime)); |
|
218 | + } |
|
207 | 219 | |
208 | 220 | return $this->setText($output); |
209 | 221 | } |
@@ -448,8 +460,9 @@ discard block |
||
448 | 460 | */ |
449 | 461 | public function getText(bool $generate = false, bool $reset = false): string |
450 | 462 | { |
451 | - if ($generate) |
|
452 | - $this->generate($reset); |
|
463 | + if ($generate) { |
|
464 | + $this->generate($reset); |
|
465 | + } |
|
453 | 466 | |
454 | 467 | return $this->text === null ? '' : $this->text; |
455 | 468 | } |
@@ -496,8 +509,9 @@ discard block |
||
496 | 509 | */ |
497 | 510 | public function addContacts(array $contacts): SecurityTxt |
498 | 511 | { |
499 | - foreach ($contacts as $contact) |
|
500 | - $this->contacts[$contact] = true; |
|
512 | + foreach ($contacts as $contact) { |
|
513 | + $this->contacts[$contact] = true; |
|
514 | + } |
|
501 | 515 | |
502 | 516 | return $this; |
503 | 517 | } |
@@ -523,9 +537,10 @@ discard block |
||
523 | 537 | */ |
524 | 538 | public function removeContacts(array $contacts): SecurityTxt |
525 | 539 | { |
526 | - foreach ($contacts as $contact) |
|
527 | - if (array_key_exists($contact, $this->contacts)) |
|
540 | + foreach ($contacts as $contact) { |
|
541 | + if (array_key_exists($contact, $this->contacts)) |
|
528 | 542 | unset($this->contacts[$contact]); |
543 | + } |
|
529 | 544 | |
530 | 545 | return $this; |
531 | 546 | } |
@@ -538,8 +553,9 @@ discard block |
||
538 | 553 | */ |
539 | 554 | public function setEncryption(string $encryption): SecurityTxt |
540 | 555 | { |
541 | - if (filter_var($encryption, FILTER_VALIDATE_URL) === false) |
|
542 | - throw new \Exception('Encryption must be a well-formed URL.'); |
|
556 | + if (filter_var($encryption, FILTER_VALIDATE_URL) === false) { |
|
557 | + throw new \Exception('Encryption must be a well-formed URL.'); |
|
558 | + } |
|
543 | 559 | |
544 | 560 | $this->encryption = $encryption; |
545 | 561 | |
@@ -564,8 +580,9 @@ discard block |
||
564 | 580 | */ |
565 | 581 | public function setDisclosure(string $disclosure): SecurityTxt |
566 | 582 | { |
567 | - if (!in_array(trim(strtolower($disclosure)), ['full', 'partial', 'none'])) |
|
568 | - throw new \Exception('Disclosure policy must be either "full", "partial", or "none".'); |
|
583 | + if (!in_array(trim(strtolower($disclosure)), ['full', 'partial', 'none'])) { |
|
584 | + throw new \Exception('Disclosure policy must be either "full", "partial", or "none".'); |
|
585 | + } |
|
569 | 586 | |
570 | 587 | $this->disclosure = $disclosure; |
571 | 588 | |
@@ -590,8 +607,9 @@ discard block |
||
590 | 607 | */ |
591 | 608 | public function setAcknowledgement(string $acknowledgement): SecurityTxt |
592 | 609 | { |
593 | - if (filter_var($acknowledgement, FILTER_VALIDATE_URL) === false) |
|
594 | - throw new \Exception('Acknowledgement must be a well-formed URL.'); |
|
610 | + if (filter_var($acknowledgement, FILTER_VALIDATE_URL) === false) { |
|
611 | + throw new \Exception('Acknowledgement must be a well-formed URL.'); |
|
612 | + } |
|
595 | 613 | |
596 | 614 | $this->acknowledgement = $acknowledgement; |
597 | 615 | |
@@ -618,8 +636,9 @@ discard block |
||
618 | 636 | { |
619 | 637 | $comment = trim($comment); |
620 | 638 | |
621 | - if (!empty($comment)) |
|
622 | - $comment = ' ' . $comment; |
|
639 | + if (!empty($comment)) { |
|
640 | + $comment = ' ' . $comment; |
|
641 | + } |
|
623 | 642 | |
624 | 643 | return $this->addLine('#' . $comment); |
625 | 644 | } |
@@ -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 | } |
@@ -145,53 +146,62 @@ discard block |
||
145 | 146 | $output = cache($this->cacheKey, null); |
146 | 147 | |
147 | 148 | if (!is_null($output) && |
148 | - is_string($output)) |
|
149 | - return $this->setText($output); |
|
149 | + is_string($output)) { |
|
150 | + return $this->setText($output); |
|
151 | + } |
|
150 | 152 | |
151 | 153 | unset($output); |
152 | 154 | } |
153 | 155 | |
154 | - if ($this->debug) |
|
155 | - $time = microtime(true); |
|
156 | + if ($this->debug) { |
|
157 | + $time = microtime(true); |
|
158 | + } |
|
156 | 159 | |
157 | - if ($reset) |
|
158 | - $this->resetLines(); |
|
160 | + if ($reset) { |
|
161 | + $this->resetLines(); |
|
162 | + } |
|
159 | 163 | |
160 | - if ($this->comments) |
|
161 | - $this->addComment('Our security address'); |
|
164 | + if ($this->comments) { |
|
165 | + $this->addComment('Our security address'); |
|
166 | + } |
|
162 | 167 | |
163 | - if (empty($this->contacts)) |
|
164 | - throw new \Exception('One (or more) contacts must be defined.'); |
|
168 | + if (empty($this->contacts)) { |
|
169 | + throw new \Exception('One (or more) contacts must be defined.'); |
|
170 | + } |
|
165 | 171 | |
166 | - foreach ($this->contacts as $contact) |
|
167 | - $this->addLine('Contact: ' . trim($contact)); |
|
172 | + foreach ($this->contacts as $contact) { |
|
173 | + $this->addLine('Contact: ' . trim($contact)); |
|
174 | + } |
|
168 | 175 | |
169 | 176 | if (!empty($this->encryption)) { |
170 | - if ($this->comments) |
|
171 | - $this->addSpacer() |
|
177 | + if ($this->comments) { |
|
178 | + $this->addSpacer() |
|
172 | 179 | ->addComment('Our PGP key'); |
180 | + } |
|
173 | 181 | |
174 | 182 | $this->addLine('Encryption: ' . trim($this->encryption)); |
175 | 183 | } |
176 | 184 | |
177 | 185 | if (!empty($this->disclosure)) { |
178 | - if ($this->comments) |
|
179 | - $this->addSpacer() |
|
186 | + if ($this->comments) { |
|
187 | + $this->addSpacer() |
|
180 | 188 | ->addComment('Our disclosure policy'); |
189 | + } |
|
181 | 190 | |
182 | 191 | $this->addLine('Disclosure: ' . trim(ucfirst($this->disclosure))); |
183 | 192 | } |
184 | 193 | |
185 | 194 | if (!empty($this->acknowledgement)) { |
186 | - if ($this->comments) |
|
187 | - $this->addSpacer() |
|
195 | + if ($this->comments) { |
|
196 | + $this->addSpacer() |
|
188 | 197 | ->addComment('Our public acknowledgement'); |
198 | + } |
|
189 | 199 | |
190 | 200 | $this->addLine('Acknowledgement: ' . trim($this->acknowledgement)); |
191 | 201 | } |
192 | 202 | |
193 | - if ($this->debug) |
|
194 | - $this->addSpacer() |
|
203 | + if ($this->debug) { |
|
204 | + $this->addSpacer() |
|
195 | 205 | ->addComment() |
196 | 206 | ->addComment('Generated by https://github.com/austinheap/laravel-security-txt') |
197 | 207 | ->addComment('in ' . round((microtime(true) - $time) * 1000, 6) . ' seconds on ' . now() . '.') |
@@ -199,11 +209,13 @@ discard block |
||
199 | 209 | ->addComment('Cache is ' . ($this->cache ? 'enabled with key "' . $this->cacheKey . '"' : 'disabled') . '.') |
200 | 210 | ->addComment() |
201 | 211 | ->addSpacer(); |
212 | + } |
|
202 | 213 | |
203 | 214 | $output = implode(PHP_EOL, $this->lines); |
204 | 215 | |
205 | - if ($this->cache) |
|
206 | - cache([$this->cacheKey => $output], now()->addMinutes($this->cacheTime)); |
|
216 | + if ($this->cache) { |
|
217 | + cache([$this->cacheKey => $output], now()->addMinutes($this->cacheTime)); |
|
218 | + } |
|
207 | 219 | |
208 | 220 | return $this->setText($output); |
209 | 221 | } |
@@ -448,8 +460,9 @@ discard block |
||
448 | 460 | */ |
449 | 461 | public function getText(bool $generate = false, bool $reset = false): string |
450 | 462 | { |
451 | - if ($generate) |
|
452 | - $this->generate($reset); |
|
463 | + if ($generate) { |
|
464 | + $this->generate($reset); |
|
465 | + } |
|
453 | 466 | |
454 | 467 | return $this->text === null ? '' : $this->text; |
455 | 468 | } |
@@ -496,8 +509,9 @@ discard block |
||
496 | 509 | */ |
497 | 510 | public function addContacts(array $contacts): SecurityTxt |
498 | 511 | { |
499 | - foreach ($contacts as $contact) |
|
500 | - $this->contacts[$contact] = true; |
|
512 | + foreach ($contacts as $contact) { |
|
513 | + $this->contacts[$contact] = true; |
|
514 | + } |
|
501 | 515 | |
502 | 516 | return $this; |
503 | 517 | } |
@@ -523,9 +537,10 @@ discard block |
||
523 | 537 | */ |
524 | 538 | public function removeContacts(array $contacts): SecurityTxt |
525 | 539 | { |
526 | - foreach ($contacts as $contact) |
|
527 | - if (array_key_exists($contact, $this->contacts)) |
|
540 | + foreach ($contacts as $contact) { |
|
541 | + if (array_key_exists($contact, $this->contacts)) |
|
528 | 542 | unset($this->contacts[$contact]); |
543 | + } |
|
529 | 544 | |
530 | 545 | return $this; |
531 | 546 | } |
@@ -538,8 +553,9 @@ discard block |
||
538 | 553 | */ |
539 | 554 | public function setEncryption(string $encryption): SecurityTxt |
540 | 555 | { |
541 | - if (filter_var($encryption, FILTER_VALIDATE_URL) === false) |
|
542 | - throw new \Exception('Encryption must be a well-formed URL.'); |
|
556 | + if (filter_var($encryption, FILTER_VALIDATE_URL) === false) { |
|
557 | + throw new \Exception('Encryption must be a well-formed URL.'); |
|
558 | + } |
|
543 | 559 | |
544 | 560 | $this->encryption = $encryption; |
545 | 561 | |
@@ -564,8 +580,9 @@ discard block |
||
564 | 580 | */ |
565 | 581 | public function setDisclosure(string $disclosure): SecurityTxt |
566 | 582 | { |
567 | - if (!in_array(trim(strtolower($disclosure)), ['full', 'partial', 'none'])) |
|
568 | - throw new \Exception('Disclosure policy must be either "full", "partial", or "none".'); |
|
583 | + if (!in_array(trim(strtolower($disclosure)), ['full', 'partial', 'none'])) { |
|
584 | + throw new \Exception('Disclosure policy must be either "full", "partial", or "none".'); |
|
585 | + } |
|
569 | 586 | |
570 | 587 | $this->disclosure = $disclosure; |
571 | 588 | |
@@ -590,8 +607,9 @@ discard block |
||
590 | 607 | */ |
591 | 608 | public function setAcknowledgement(string $acknowledgement): SecurityTxt |
592 | 609 | { |
593 | - if (filter_var($acknowledgement, FILTER_VALIDATE_URL) === false) |
|
594 | - throw new \Exception('Acknowledgement must be a well-formed URL.'); |
|
610 | + if (filter_var($acknowledgement, FILTER_VALIDATE_URL) === false) { |
|
611 | + throw new \Exception('Acknowledgement must be a well-formed URL.'); |
|
612 | + } |
|
595 | 613 | |
596 | 614 | $this->acknowledgement = $acknowledgement; |
597 | 615 | |
@@ -618,8 +636,9 @@ discard block |
||
618 | 636 | { |
619 | 637 | $comment = trim($comment); |
620 | 638 | |
621 | - if (!empty($comment)) |
|
622 | - $comment = ' ' . $comment; |
|
639 | + if (!empty($comment)) { |
|
640 | + $comment = ' ' . $comment; |
|
641 | + } |
|
623 | 642 | |
624 | 643 | return $this->addLine('#' . $comment); |
625 | 644 | } |