Passed
Branch master (c4d92f)
by Austin
03:03
created
src/Writer.php 3 patches
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
         if (!empty($this->encryption)) {
170 170
             if ($this->comments)
171 171
                 $this->addSpacer()
172
-                     ->addComment('Our PGP key');
172
+                        ->addComment('Our PGP key');
173 173
 
174 174
             $this->addLine('Encryption: ' . trim($this->encryption));
175 175
         }
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
         if (!empty($this->disclosure)) {
178 178
             if ($this->comments)
179 179
                 $this->addSpacer()
180
-                     ->addComment('Our disclosure policy');
180
+                        ->addComment('Our disclosure policy');
181 181
 
182 182
             $this->addLine('Disclosure: ' . trim(ucfirst($this->disclosure)));
183 183
         }
@@ -185,20 +185,20 @@  discard block
 block discarded – undo
185 185
         if (!empty($this->acknowledgement)) {
186 186
             if ($this->comments)
187 187
                 $this->addSpacer()
188
-                     ->addComment('Our public acknowledgement');
188
+                        ->addComment('Our public acknowledgement');
189 189
 
190 190
             $this->addLine('Acknowledgement: ' . trim($this->acknowledgement));
191 191
         }
192 192
 
193 193
         if ($this->debug)
194 194
             $this->addSpacer()
195
-                 ->addComment()
196
-                 ->addComment('Generated by https://github.com/austinheap/laravel-security-txt')
197
-                 ->addComment('in ' . round((microtime(true) - $time) * 1000, 6) . ' seconds on ' . now() . '.')
198
-                 ->addComment()
199
-                 ->addComment('Cache is ' . ($this->cache ? 'enabled with key "' . $this->cacheKey . '"' : 'disabled') . '.')
200
-                 ->addComment()
201
-                 ->addSpacer();
195
+                    ->addComment()
196
+                    ->addComment('Generated by https://github.com/austinheap/laravel-security-txt')
197
+                    ->addComment('in ' . round((microtime(true) - $time) * 1000, 6) . ' seconds on ' . now() . '.')
198
+                    ->addComment()
199
+                    ->addComment('Cache is ' . ($this->cache ? 'enabled with key "' . $this->cacheKey . '"' : 'disabled') . '.')
200
+                    ->addComment()
201
+                    ->addSpacer();
202 202
 
203 203
         $output = implode(PHP_EOL, $this->lines);
204 204
 
Please login to merge, or discard this patch.
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
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,84 +26,84 @@  discard block
 block discarded – undo
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.
@@ -113,16 +113,16 @@  discard block
 block discarded – undo
113 113
     public function __construct()
114 114
     {
115 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'],
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)
@@ -164,14 +164,14 @@  discard block
 block discarded – undo
164 164
             throw new \Exception('One (or more) contacts must be defined.');
165 165
 
166 166
         foreach ($this->contacts as $contact)
167
-            $this->addLine('Contact: ' . trim($contact));
167
+            $this->addLine('Contact: '.trim($contact));
168 168
 
169 169
         if (!empty($this->encryption)) {
170 170
             if ($this->comments)
171 171
                 $this->addSpacer()
172 172
                      ->addComment('Our PGP key');
173 173
 
174
-            $this->addLine('Encryption: ' . trim($this->encryption));
174
+            $this->addLine('Encryption: '.trim($this->encryption));
175 175
         }
176 176
 
177 177
         if (!empty($this->disclosure)) {
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
                 $this->addSpacer()
180 180
                      ->addComment('Our disclosure policy');
181 181
 
182
-            $this->addLine('Disclosure: ' . trim(ucfirst($this->disclosure)));
182
+            $this->addLine('Disclosure: '.trim(ucfirst($this->disclosure)));
183 183
         }
184 184
 
185 185
         if (!empty($this->acknowledgement)) {
@@ -187,16 +187,16 @@  discard block
 block discarded – undo
187 187
                 $this->addSpacer()
188 188
                      ->addComment('Our public acknowledgement');
189 189
 
190
-            $this->addLine('Acknowledgement: ' . trim($this->acknowledgement));
190
+            $this->addLine('Acknowledgement: '.trim($this->acknowledgement));
191 191
         }
192 192
 
193 193
         if ($this->debug)
194 194
             $this->addSpacer()
195 195
                  ->addComment()
196 196
                  ->addComment('Generated by https://github.com/austinheap/laravel-security-txt')
197
-                 ->addComment('in ' . round((microtime(true) - $time) * 1000, 6) . ' seconds on ' . now() . '.')
197
+                 ->addComment('in '.round((microtime(true) - $time) * 1000, 6).' seconds on '.now().'.')
198 198
                  ->addComment()
199
-                 ->addComment('Cache is ' . ($this->cache ? 'enabled with key "' . $this->cacheKey . '"' : 'disabled') . '.')
199
+                 ->addComment('Cache is '.($this->cache ? 'enabled with key "'.$this->cacheKey.'"' : 'disabled').'.')
200 200
                  ->addComment()
201 201
                  ->addSpacer();
202 202
 
@@ -619,9 +619,9 @@  discard block
 block discarded – undo
619 619
         $comment = trim($comment);
620 620
 
621 621
         if (!empty($comment))
622
-            $comment = ' ' . $comment;
622
+            $comment = ' '.$comment;
623 623
 
624
-        return $this->addLine('#' . $comment);
624
+        return $this->addLine('#'.$comment);
625 625
     }
626 626
 
627 627
     /**
Please login to merge, or discard this patch.
Braces   +57 added lines, -38 removed lines patch added patch discarded remove patch
@@ -125,10 +125,11 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
     }
Please login to merge, or discard this patch.
src/SecurityTxt.php 3 patches
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
         if (!empty($this->encryption)) {
170 170
             if ($this->comments)
171 171
                 $this->addSpacer()
172
-                     ->addComment('Our PGP key');
172
+                        ->addComment('Our PGP key');
173 173
 
174 174
             $this->addLine('Encryption: ' . trim($this->encryption));
175 175
         }
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
         if (!empty($this->disclosure)) {
178 178
             if ($this->comments)
179 179
                 $this->addSpacer()
180
-                     ->addComment('Our disclosure policy');
180
+                        ->addComment('Our disclosure policy');
181 181
 
182 182
             $this->addLine('Disclosure: ' . trim(ucfirst($this->disclosure)));
183 183
         }
@@ -185,20 +185,20 @@  discard block
 block discarded – undo
185 185
         if (!empty($this->acknowledgement)) {
186 186
             if ($this->comments)
187 187
                 $this->addSpacer()
188
-                     ->addComment('Our public acknowledgement');
188
+                        ->addComment('Our public acknowledgement');
189 189
 
190 190
             $this->addLine('Acknowledgement: ' . trim($this->acknowledgement));
191 191
         }
192 192
 
193 193
         if ($this->debug)
194 194
             $this->addSpacer()
195
-                 ->addComment()
196
-                 ->addComment('Generated by https://github.com/austinheap/laravel-security-txt')
197
-                 ->addComment('in ' . round((microtime(true) - $time) * 1000, 6) . ' seconds on ' . now() . '.')
198
-                 ->addComment()
199
-                 ->addComment('Cache is ' . ($this->cache ? 'enabled with key "' . $this->cacheKey . '"' : 'disabled') . '.')
200
-                 ->addComment()
201
-                 ->addSpacer();
195
+                    ->addComment()
196
+                    ->addComment('Generated by https://github.com/austinheap/laravel-security-txt')
197
+                    ->addComment('in ' . round((microtime(true) - $time) * 1000, 6) . ' seconds on ' . now() . '.')
198
+                    ->addComment()
199
+                    ->addComment('Cache is ' . ($this->cache ? 'enabled with key "' . $this->cacheKey . '"' : 'disabled') . '.')
200
+                    ->addComment()
201
+                    ->addSpacer();
202 202
 
203 203
         $output = implode(PHP_EOL, $this->lines);
204 204
 
Please login to merge, or discard this patch.
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
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,84 +26,84 @@  discard block
 block discarded – undo
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.
@@ -113,16 +113,16 @@  discard block
 block discarded – undo
113 113
     public function __construct()
114 114
     {
115 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'],
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)
@@ -164,14 +164,14 @@  discard block
 block discarded – undo
164 164
             throw new \Exception('One (or more) contacts must be defined.');
165 165
 
166 166
         foreach ($this->contacts as $contact)
167
-            $this->addLine('Contact: ' . trim($contact));
167
+            $this->addLine('Contact: '.trim($contact));
168 168
 
169 169
         if (!empty($this->encryption)) {
170 170
             if ($this->comments)
171 171
                 $this->addSpacer()
172 172
                      ->addComment('Our PGP key');
173 173
 
174
-            $this->addLine('Encryption: ' . trim($this->encryption));
174
+            $this->addLine('Encryption: '.trim($this->encryption));
175 175
         }
176 176
 
177 177
         if (!empty($this->disclosure)) {
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
                 $this->addSpacer()
180 180
                      ->addComment('Our disclosure policy');
181 181
 
182
-            $this->addLine('Disclosure: ' . trim(ucfirst($this->disclosure)));
182
+            $this->addLine('Disclosure: '.trim(ucfirst($this->disclosure)));
183 183
         }
184 184
 
185 185
         if (!empty($this->acknowledgement)) {
@@ -187,16 +187,16 @@  discard block
 block discarded – undo
187 187
                 $this->addSpacer()
188 188
                      ->addComment('Our public acknowledgement');
189 189
 
190
-            $this->addLine('Acknowledgement: ' . trim($this->acknowledgement));
190
+            $this->addLine('Acknowledgement: '.trim($this->acknowledgement));
191 191
         }
192 192
 
193 193
         if ($this->debug)
194 194
             $this->addSpacer()
195 195
                  ->addComment()
196 196
                  ->addComment('Generated by https://github.com/austinheap/laravel-security-txt')
197
-                 ->addComment('in ' . round((microtime(true) - $time) * 1000, 6) . ' seconds on ' . now() . '.')
197
+                 ->addComment('in '.round((microtime(true) - $time) * 1000, 6).' seconds on '.now().'.')
198 198
                  ->addComment()
199
-                 ->addComment('Cache is ' . ($this->cache ? 'enabled with key "' . $this->cacheKey . '"' : 'disabled') . '.')
199
+                 ->addComment('Cache is '.($this->cache ? 'enabled with key "'.$this->cacheKey.'"' : 'disabled').'.')
200 200
                  ->addComment()
201 201
                  ->addSpacer();
202 202
 
@@ -619,9 +619,9 @@  discard block
 block discarded – undo
619 619
         $comment = trim($comment);
620 620
 
621 621
         if (!empty($comment))
622
-            $comment = ' ' . $comment;
622
+            $comment = ' '.$comment;
623 623
 
624
-        return $this->addLine('#' . $comment);
624
+        return $this->addLine('#'.$comment);
625 625
     }
626 626
 
627 627
     /**
Please login to merge, or discard this patch.
Braces   +57 added lines, -38 removed lines patch added patch discarded remove patch
@@ -125,10 +125,11 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
     }
Please login to merge, or discard this patch.
src/Reader.php 3 patches
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
         if (!empty($this->encryption)) {
170 170
             if ($this->comments)
171 171
                 $this->addSpacer()
172
-                     ->addComment('Our PGP key');
172
+                        ->addComment('Our PGP key');
173 173
 
174 174
             $this->addLine('Encryption: ' . trim($this->encryption));
175 175
         }
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
         if (!empty($this->disclosure)) {
178 178
             if ($this->comments)
179 179
                 $this->addSpacer()
180
-                     ->addComment('Our disclosure policy');
180
+                        ->addComment('Our disclosure policy');
181 181
 
182 182
             $this->addLine('Disclosure: ' . trim(ucfirst($this->disclosure)));
183 183
         }
@@ -185,20 +185,20 @@  discard block
 block discarded – undo
185 185
         if (!empty($this->acknowledgement)) {
186 186
             if ($this->comments)
187 187
                 $this->addSpacer()
188
-                     ->addComment('Our public acknowledgement');
188
+                        ->addComment('Our public acknowledgement');
189 189
 
190 190
             $this->addLine('Acknowledgement: ' . trim($this->acknowledgement));
191 191
         }
192 192
 
193 193
         if ($this->debug)
194 194
             $this->addSpacer()
195
-                 ->addComment()
196
-                 ->addComment('Generated by https://github.com/austinheap/laravel-security-txt')
197
-                 ->addComment('in ' . round((microtime(true) - $time) * 1000, 6) . ' seconds on ' . now() . '.')
198
-                 ->addComment()
199
-                 ->addComment('Cache is ' . ($this->cache ? 'enabled with key "' . $this->cacheKey . '"' : 'disabled') . '.')
200
-                 ->addComment()
201
-                 ->addSpacer();
195
+                    ->addComment()
196
+                    ->addComment('Generated by https://github.com/austinheap/laravel-security-txt')
197
+                    ->addComment('in ' . round((microtime(true) - $time) * 1000, 6) . ' seconds on ' . now() . '.')
198
+                    ->addComment()
199
+                    ->addComment('Cache is ' . ($this->cache ? 'enabled with key "' . $this->cacheKey . '"' : 'disabled') . '.')
200
+                    ->addComment()
201
+                    ->addSpacer();
202 202
 
203 203
         $output = implode(PHP_EOL, $this->lines);
204 204
 
Please login to merge, or discard this patch.
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
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,84 +26,84 @@  discard block
 block discarded – undo
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.
@@ -113,16 +113,16 @@  discard block
 block discarded – undo
113 113
     public function __construct()
114 114
     {
115 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'],
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)
@@ -164,14 +164,14 @@  discard block
 block discarded – undo
164 164
             throw new \Exception('One (or more) contacts must be defined.');
165 165
 
166 166
         foreach ($this->contacts as $contact)
167
-            $this->addLine('Contact: ' . trim($contact));
167
+            $this->addLine('Contact: '.trim($contact));
168 168
 
169 169
         if (!empty($this->encryption)) {
170 170
             if ($this->comments)
171 171
                 $this->addSpacer()
172 172
                      ->addComment('Our PGP key');
173 173
 
174
-            $this->addLine('Encryption: ' . trim($this->encryption));
174
+            $this->addLine('Encryption: '.trim($this->encryption));
175 175
         }
176 176
 
177 177
         if (!empty($this->disclosure)) {
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
                 $this->addSpacer()
180 180
                      ->addComment('Our disclosure policy');
181 181
 
182
-            $this->addLine('Disclosure: ' . trim(ucfirst($this->disclosure)));
182
+            $this->addLine('Disclosure: '.trim(ucfirst($this->disclosure)));
183 183
         }
184 184
 
185 185
         if (!empty($this->acknowledgement)) {
@@ -187,16 +187,16 @@  discard block
 block discarded – undo
187 187
                 $this->addSpacer()
188 188
                      ->addComment('Our public acknowledgement');
189 189
 
190
-            $this->addLine('Acknowledgement: ' . trim($this->acknowledgement));
190
+            $this->addLine('Acknowledgement: '.trim($this->acknowledgement));
191 191
         }
192 192
 
193 193
         if ($this->debug)
194 194
             $this->addSpacer()
195 195
                  ->addComment()
196 196
                  ->addComment('Generated by https://github.com/austinheap/laravel-security-txt')
197
-                 ->addComment('in ' . round((microtime(true) - $time) * 1000, 6) . ' seconds on ' . now() . '.')
197
+                 ->addComment('in '.round((microtime(true) - $time) * 1000, 6).' seconds on '.now().'.')
198 198
                  ->addComment()
199
-                 ->addComment('Cache is ' . ($this->cache ? 'enabled with key "' . $this->cacheKey . '"' : 'disabled') . '.')
199
+                 ->addComment('Cache is '.($this->cache ? 'enabled with key "'.$this->cacheKey.'"' : 'disabled').'.')
200 200
                  ->addComment()
201 201
                  ->addSpacer();
202 202
 
@@ -619,9 +619,9 @@  discard block
 block discarded – undo
619 619
         $comment = trim($comment);
620 620
 
621 621
         if (!empty($comment))
622
-            $comment = ' ' . $comment;
622
+            $comment = ' '.$comment;
623 623
 
624
-        return $this->addLine('#' . $comment);
624
+        return $this->addLine('#'.$comment);
625 625
     }
626 626
 
627 627
     /**
Please login to merge, or discard this patch.
Braces   +57 added lines, -38 removed lines patch added patch discarded remove patch
@@ -125,10 +125,11 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
     }
Please login to merge, or discard this patch.