Passed
Push — master ( 69f647...6585a1 )
by Sebastian
04:37
created
src/OperationResult.php 2 patches
Indentation   +73 added lines, -73 removed lines patch added patch discarded remove patch
@@ -32,46 +32,46 @@  discard block
 block discarded – undo
32 32
     const TYPE_ERROR = 'error';
33 33
     const TYPE_SUCCESS = 'success';
34 34
     
35
-   /**
36
-    * @var string
37
-    */
35
+    /**
36
+     * @var string
37
+     */
38 38
     protected $message = '';
39 39
     
40
-   /**
41
-    * @var bool
42
-    */
40
+    /**
41
+     * @var bool
42
+     */
43 43
     protected $valid = true;
44 44
   
45
-   /**
46
-    * @var object
47
-    */
45
+    /**
46
+     * @var object
47
+     */
48 48
     protected $subject;
49 49
     
50
-   /**
51
-    * @var integer
52
-    */
50
+    /**
51
+     * @var integer
52
+     */
53 53
     protected $code = 0;
54 54
     
55
-   /**
56
-    * @var string
57
-    */
55
+    /**
56
+     * @var string
57
+     */
58 58
     protected $type = '';
59 59
     
60
-   /**
61
-    * @var integer
62
-    */
60
+    /**
61
+     * @var integer
62
+     */
63 63
     private static $counter = 0;
64 64
     
65
-   /**
66
-    * @var int
67
-    */
65
+    /**
66
+     * @var int
67
+     */
68 68
     private $id;
69 69
     
70
-   /**
71
-    * The subject being validated.
72
-    * 
73
-    * @param object $subject
74
-    */
70
+    /**
71
+     * The subject being validated.
72
+     * 
73
+     * @param object $subject
74
+     */
75 75
     public function __construct(object $subject)
76 76
     {
77 77
         $this->subject = $subject;
@@ -81,21 +81,21 @@  discard block
 block discarded – undo
81 81
         $this->id = self::$counter;
82 82
     }
83 83
     
84
-   /**
85
-    * Retrieves the ID of the result, which is unique within a request.
86
-    * 
87
-    * @return int
88
-    */
84
+    /**
85
+     * Retrieves the ID of the result, which is unique within a request.
86
+     * 
87
+     * @return int
88
+     */
89 89
     public function getID() : int
90 90
     {
91 91
         return $this->id;
92 92
     }
93 93
     
94
-   /**
95
-    * Whether the validation was successful.
96
-    * 
97
-    * @return bool
98
-    */
94
+    /**
95
+     * Whether the validation was successful.
96
+     * 
97
+     * @return bool
98
+     */
99 99
     public function isValid() : bool
100 100
     {
101 101
         return $this->valid;
@@ -126,33 +126,33 @@  discard block
 block discarded – undo
126 126
         return $this->type === $type;
127 127
     }
128 128
     
129
-   /**
130
-    * Retrieves the subject that was validated.
131
-    * 
132
-    * @return object
133
-    */
129
+    /**
130
+     * Retrieves the subject that was validated.
131
+     * 
132
+     * @return object
133
+     */
134 134
     public function getSubject() : object
135 135
     {
136 136
         return $this->subject;
137 137
     }
138 138
     
139
-   /**
140
-    * Makes the result a succes, with the specified message.
141
-    * 
142
-    * @param string $message Should not contain a date, just the system specific info.
143
-    * @return OperationResult
144
-    */
139
+    /**
140
+     * Makes the result a succes, with the specified message.
141
+     * 
142
+     * @param string $message Should not contain a date, just the system specific info.
143
+     * @return OperationResult
144
+     */
145 145
     public function makeSuccess(string $message, int $code=0) : OperationResult
146 146
     {
147 147
         return $this->setMessage(self::TYPE_SUCCESS, $message, $code, true);
148 148
     }
149 149
     
150
-   /**
151
-    * Sets the result as an error.
152
-    * 
153
-    * @param string $message Should be as detailed as possible.
154
-    * @return OperationResult
155
-    */
150
+    /**
151
+     * Sets the result as an error.
152
+     * 
153
+     * @param string $message Should be as detailed as possible.
154
+     * @return OperationResult
155
+     */
156 156
     public function makeError(string $message, int $code=0) : OperationResult
157 157
     {
158 158
         return $this->setMessage(self::TYPE_ERROR, $message, $code, false);
@@ -183,21 +183,21 @@  discard block
 block discarded – undo
183 183
         return $this->type;
184 184
     }
185 185
     
186
-   /**
187
-    * Retrieves the error message, if an error occurred.
188
-    * 
189
-    * @return string The error message, or an empty string if no error occurred.
190
-    */
186
+    /**
187
+     * Retrieves the error message, if an error occurred.
188
+     * 
189
+     * @return string The error message, or an empty string if no error occurred.
190
+     */
191 191
     public function getErrorMessage() : string
192 192
     {
193 193
         return $this->getMessage(self::TYPE_ERROR);
194 194
     }
195 195
     
196
-   /**
197
-    * Retrieves the success message, if one has been provided.
198
-    * 
199
-    * @return string
200
-    */
196
+    /**
197
+     * Retrieves the success message, if one has been provided.
198
+     * 
199
+     * @return string
200
+     */
201 201
     public function getSuccessMessage() : string
202 202
     {
203 203
         return $this->getMessage(self::TYPE_SUCCESS);
@@ -213,21 +213,21 @@  discard block
 block discarded – undo
213 213
         return $this->getMessage(self::TYPE_WARNING);
214 214
     }
215 215
     
216
-   /**
217
-    * Whether a specific error/success code has been specified.
218
-    * 
219
-    * @return bool
220
-    */
216
+    /**
217
+     * Whether a specific error/success code has been specified.
218
+     * 
219
+     * @return bool
220
+     */
221 221
     public function hasCode() : bool
222 222
     {
223 223
         return $this->code > 0;
224 224
     }
225 225
     
226
-   /**
227
-    * Retrieves the error/success code, if any. 
228
-    * 
229
-    * @return int The error code, or 0 if none.
230
-    */
226
+    /**
227
+     * Retrieves the error/success code, if any. 
228
+     * 
229
+     * @return int The error code, or 0 if none.
230
+     */
231 231
     public function getCode() : int
232 232
     {
233 233
         return $this->code;
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
     * @param string $message Should not contain a date, just the system specific info.
143 143
     * @return OperationResult
144 144
     */
145
-    public function makeSuccess(string $message, int $code=0) : OperationResult
145
+    public function makeSuccess(string $message, int $code = 0) : OperationResult
146 146
     {
147 147
         return $this->setMessage(self::TYPE_SUCCESS, $message, $code, true);
148 148
     }
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
     * @param string $message Should be as detailed as possible.
154 154
     * @return OperationResult
155 155
     */
156
-    public function makeError(string $message, int $code=0) : OperationResult
156
+    public function makeError(string $message, int $code = 0) : OperationResult
157 157
     {
158 158
         return $this->setMessage(self::TYPE_ERROR, $message, $code, false);
159 159
     }
@@ -233,11 +233,11 @@  discard block
 block discarded – undo
233 233
         return $this->code;
234 234
     }
235 235
     
236
-    public function getMessage(string $type='') : string
236
+    public function getMessage(string $type = '') : string
237 237
     {
238
-        if(!empty($type))
238
+        if (!empty($type))
239 239
         {
240
-            if($this->type === $type)
240
+            if ($this->type === $type)
241 241
             {
242 242
                 return $this->message;
243 243
             }
Please login to merge, or discard this patch.
src/OperationResult/Collection.php 2 patches
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -26,9 +26,9 @@  discard block
 block discarded – undo
26 26
  */
27 27
 class OperationResult_Collection extends OperationResult
28 28
 {
29
-   /**
30
-    * @var OperationResult[]
31
-    */
29
+    /**
30
+     * @var OperationResult[]
31
+     */
32 32
     protected $results = array();
33 33
     
34 34
     public function makeError(string $message, int $code=0) : OperationResult
@@ -106,9 +106,9 @@  discard block
 block discarded – undo
106 106
         return $this;
107 107
     }
108 108
     
109
-   /**
110
-    * @return OperationResult[]
111
-    */
109
+    /**
110
+     * @return OperationResult[]
111
+     */
112 112
     public function getResults() : array
113 113
     {
114 114
         return $this->results;
Please login to merge, or discard this patch.
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -31,27 +31,27 @@  discard block
 block discarded – undo
31 31
     */
32 32
     protected $results = array();
33 33
     
34
-    public function makeError(string $message, int $code=0) : OperationResult
34
+    public function makeError(string $message, int $code = 0) : OperationResult
35 35
     {
36 36
         return $this->add('makeError', $message, $code);
37 37
     }
38 38
     
39
-    public function makeSuccess(string $message, int $code=0) : OperationResult
39
+    public function makeSuccess(string $message, int $code = 0) : OperationResult
40 40
     {
41 41
         return $this->add('makeSuccess', $message, $code);
42 42
     }
43 43
 
44
-    public function makeWarning(string $message, int $code=0) : OperationResult
44
+    public function makeWarning(string $message, int $code = 0) : OperationResult
45 45
     {
46 46
         return $this->add('makeWarning', $message, $code);
47 47
     }
48 48
     
49
-    public function makeNotice(string $message, int $code=0) : OperationResult
49
+    public function makeNotice(string $message, int $code = 0) : OperationResult
50 50
     {
51 51
         return $this->add('makeNotice', $message, $code);
52 52
     }
53 53
     
54
-    protected function add(string $method, string $message, int $code=0) : OperationResult
54
+    protected function add(string $method, string $message, int $code = 0) : OperationResult
55 55
     {
56 56
         $result = new OperationResult($this->subject);
57 57
         $result->$method($message, $code);
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
     
64 64
     public function addResult(OperationResult $result) : OperationResult_Collection
65 65
     {
66
-        if($result instanceof OperationResult_Collection)
66
+        if ($result instanceof OperationResult_Collection)
67 67
         {
68 68
             return $this->importCollection($result);
69 69
         }
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
     {
76 76
         $results = $collection->getResults();
77 77
         
78
-        foreach($results as $result)
78
+        foreach ($results as $result)
79 79
         {
80 80
             $this->addResult($result);
81 81
         }
@@ -111,9 +111,9 @@  discard block
 block discarded – undo
111 111
     
112 112
     public function isValid() : bool
113 113
     {
114
-        foreach($this->results as $result)
114
+        foreach ($this->results as $result)
115 115
         {
116
-            if(!$result->isValid())
116
+            if (!$result->isValid())
117 117
             {
118 118
                 return false;
119 119
             }
@@ -124,9 +124,9 @@  discard block
 block discarded – undo
124 124
     
125 125
     public function hasCode() : bool
126 126
     {
127
-        foreach($this->results as $result)
127
+        foreach ($this->results as $result)
128 128
         {
129
-            if($result->hasCode())
129
+            if ($result->hasCode())
130 130
             {
131 131
                 return true;
132 132
             }
@@ -137,9 +137,9 @@  discard block
 block discarded – undo
137 137
     
138 138
     public function getCode() : int
139 139
     {
140
-        foreach($this->results as $result)
140
+        foreach ($this->results as $result)
141 141
         {
142
-            if($result->hasCode())
142
+            if ($result->hasCode())
143 143
             {
144 144
                 return $result->getCode();
145 145
             }
@@ -148,13 +148,13 @@  discard block
 block discarded – undo
148 148
         return 0;
149 149
     }
150 150
     
151
-    public function getMessage(string $type='') : string
151
+    public function getMessage(string $type = '') : string
152 152
     {
153
-        foreach($this->results as $result)
153
+        foreach ($this->results as $result)
154 154
         {
155 155
             $msg = $result->getMessage($type);
156 156
             
157
-            if(!empty($msg))
157
+            if (!empty($msg))
158 158
             {
159 159
                 return $msg;
160 160
             }
@@ -165,9 +165,9 @@  discard block
 block discarded – undo
165 165
     
166 166
     public function containsCode(int $code) : bool
167 167
     {
168
-        foreach($this->results as $result)
168
+        foreach ($this->results as $result)
169 169
         {
170
-            if($result->getCode() === $code)
170
+            if ($result->getCode() === $code)
171 171
             {
172 172
                 return true;
173 173
             }
@@ -200,9 +200,9 @@  discard block
 block discarded – undo
200 200
     {
201 201
         $amount = 0;
202 202
         
203
-        foreach($this->results as $result)
203
+        foreach ($this->results as $result)
204 204
         {
205
-            if($result->isType($type))
205
+            if ($result->isType($type))
206 206
             {
207 207
                 $amount++;
208 208
             }
@@ -240,9 +240,9 @@  discard block
 block discarded – undo
240 240
     {
241 241
         $results = array();
242 242
         
243
-        foreach($this->results as $result)
243
+        foreach ($this->results as $result)
244 244
         {
245
-            if($result->isType($type))
245
+            if ($result->isType($type))
246 246
             {
247 247
                 $results[] = $result;
248 248
             }
@@ -253,9 +253,9 @@  discard block
 block discarded – undo
253 253
     
254 254
     public function isType(string $type) : bool
255 255
     {
256
-        foreach($this->results as $result)
256
+        foreach ($this->results as $result)
257 257
         {
258
-            if($result->isType($type))
258
+            if ($result->isType($type))
259 259
             {
260 260
                 return true;
261 261
             }
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
         $lines[] = 'Collection #'.$this->getID();
272 272
         $lines[] = 'Subject: '.get_class($this->subject);
273 273
         
274
-        foreach($this->results as $result)
274
+        foreach ($this->results as $result)
275 275
         {
276 276
             $lines[] = ' - '.$result->getType().' #'.$result->getCode().' "'.$result->getMessage($result->getType()).'"';
277 277
         }
Please login to merge, or discard this patch.
src/Traits/Classable.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
     
33 33
     public function addClass(string $name)
34 34
     {
35
-        if(!in_array($name, $this->classes)) {
35
+        if (!in_array($name, $this->classes)) {
36 36
             $this->classes[] = $name;
37 37
         }
38 38
         
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
     
42 42
     public function addClasses(array $names)
43 43
     {
44
-        foreach($names as $name) {
44
+        foreach ($names as $name) {
45 45
             $this->addClass($name);
46 46
         }
47 47
         
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
     {
58 58
         $idx = array_search($name, $this->classes);
59 59
         
60
-        if($idx !== false) {
60
+        if ($idx !== false) {
61 61
             unset($this->classes[$idx]);
62 62
             sort($this->classes);
63 63
         }
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
     */
92 92
     public function classesToAttribute() : string
93 93
     {
94
-        if(!empty($this->classes))
94
+        if (!empty($this->classes))
95 95
         {
96 96
             return sprintf(
97 97
                 ' class="%s" ',
Please login to merge, or discard this patch.
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -25,9 +25,9 @@  discard block
 block discarded – undo
25 25
  */
26 26
 trait Traits_Classable
27 27
 {
28
-   /**
29
-    * @var string[]
30
-    */
28
+    /**
29
+     * @var string[]
30
+     */
31 31
     protected $classes = array();
32 32
     
33 33
     public function addClass(string $name)
@@ -65,30 +65,30 @@  discard block
 block discarded – undo
65 65
         return $this;
66 66
     }
67 67
     
68
-   /**
69
-    * Retrieves a list of all classes, if any.
70
-    * 
71
-    * @return string[]
72
-    */
68
+    /**
69
+     * Retrieves a list of all classes, if any.
70
+     * 
71
+     * @return string[]
72
+     */
73 73
     public function getClasses() : array
74 74
     {
75 75
         return $this->classes;
76 76
     }
77 77
     
78
-   /**
79
-    * Renders the class names list as space-separated string for use in an HTML tag.
80
-    * 
81
-    * @return string
82
-    */
78
+    /**
79
+     * Renders the class names list as space-separated string for use in an HTML tag.
80
+     * 
81
+     * @return string
82
+     */
83 83
     public function classesToString() : string
84 84
     {
85 85
         return implode(' ', $this->classes);
86 86
     }
87 87
     
88
-   /**
89
-    * Renders the "class" attribute string for inserting into an HTML tag.
90
-    * @return string
91
-    */
88
+    /**
89
+     * Renders the "class" attribute string for inserting into an HTML tag.
90
+     * @return string
91
+     */
92 92
     public function classesToAttribute() : string
93 93
     {
94 94
         if(!empty($this->classes))
Please login to merge, or discard this patch.
src/Request.php 2 patches
Indentation   +142 added lines, -142 removed lines patch added patch discarded remove patch
@@ -39,9 +39,9 @@  discard block
 block discarded – undo
39 39
      */
40 40
     protected static $instance;
41 41
     
42
-   /**
43
-    * @var string
44
-    */
42
+    /**
43
+     * @var string
44
+     */
45 45
     protected $baseURL = '';
46 46
     
47 47
     public function __construct()
@@ -51,10 +51,10 @@  discard block
 block discarded – undo
51 51
         $this->init();
52 52
     }
53 53
     
54
-   /**
55
-    * Can be extended in a subclass, to avoid
56
-    * redefining the constructor.
57
-    */
54
+    /**
55
+     * Can be extended in a subclass, to avoid
56
+     * redefining the constructor.
57
+     */
58 58
     protected function init()
59 59
     {
60 60
         
@@ -126,30 +126,30 @@  discard block
 block discarded – undo
126 126
         return $this->buildURL($params, $dispatcher);
127 127
     }
128 128
     
129
-   /**
130
-    * Retrieves the name of the current dispatcher script / page.
131
-    * This is made to be extended and implemented in a subclass.
132
-    * 
133
-    * @return string
134
-    */
129
+    /**
130
+     * Retrieves the name of the current dispatcher script / page.
131
+     * This is made to be extended and implemented in a subclass.
132
+     * 
133
+     * @return string
134
+     */
135 135
     public function getDispatcher() : string
136 136
     {
137 137
         return '';
138 138
     }
139 139
     
140
-   /**
141
-    * Filters and retrieves the current request variables 
142
-    * to be used to build an URL to refresh the current page.
143
-    * 
144
-    * For further customization options, use the 
145
-    * {@see Request::createRefreshParams()} method.
146
-    * 
147
-    * @param array<string,mixed> $params Key => value pairs of parameters to always include in the result.
148
-    * @param string[] $exclude Names of parameters to exclude from the result.
149
-    * @return array<string,mixed>
150
-    * 
151
-    * @see Request::createRefreshParams()
152
-    */
140
+    /**
141
+     * Filters and retrieves the current request variables 
142
+     * to be used to build an URL to refresh the current page.
143
+     * 
144
+     * For further customization options, use the 
145
+     * {@see Request::createRefreshParams()} method.
146
+     * 
147
+     * @param array<string,mixed> $params Key => value pairs of parameters to always include in the result.
148
+     * @param string[] $exclude Names of parameters to exclude from the result.
149
+     * @return array<string,mixed>
150
+     * 
151
+     * @see Request::createRefreshParams()
152
+     */
153 153
     public function getRefreshParams(array $params = array(), array $exclude = array())
154 154
     {
155 155
         return $this->createRefreshParams()
@@ -158,13 +158,13 @@  discard block
 block discarded – undo
158 158
         ->getParams();
159 159
     }
160 160
     
161
-   /**
162
-    * Creates an instance of the helper that can be used to
163
-    * retrieve the request's parameters collection, with the
164
-    * possiblity to exlude and override some by rules.
165
-    * 
166
-    * @return Request_RefreshParams
167
-    */
161
+    /**
162
+     * Creates an instance of the helper that can be used to
163
+     * retrieve the request's parameters collection, with the
164
+     * possiblity to exlude and override some by rules.
165
+     * 
166
+     * @return Request_RefreshParams
167
+     */
168 168
     public function createRefreshParams() : Request_RefreshParams
169 169
     {
170 170
         return new Request_RefreshParams();
@@ -197,10 +197,10 @@  discard block
 block discarded – undo
197 197
         return $url;
198 198
     }
199 199
     
200
-   /**
201
-    * Retrieves the base URL of the application.
202
-    * @return string
203
-    */
200
+    /**
201
+     * Retrieves the base URL of the application.
202
+     * @return string
203
+     */
204 204
     public function getBaseURL() : string
205 205
     {
206 206
         return $this->baseURL;
@@ -230,13 +230,13 @@  discard block
 block discarded – undo
230 230
         return $this->knownParams[$name];
231 231
     }
232 232
     
233
-   /**
234
-    * Retrieves a previously registered parameter instance.
235
-    * 
236
-    * @param string $name
237
-    * @throws Request_Exception
238
-    * @return Request_Param
239
-    */
233
+    /**
234
+     * Retrieves a previously registered parameter instance.
235
+     * 
236
+     * @param string $name
237
+     * @throws Request_Exception
238
+     * @return Request_Param
239
+     */
240 240
     public function getRegisteredParam(string $name) : Request_Param
241 241
     {
242 242
         if(isset($this->knownParams[$name])) {
@@ -253,48 +253,48 @@  discard block
 block discarded – undo
253 253
         );
254 254
     }
255 255
     
256
-   /**
257
-    * Checks whether a parameter with the specified name 
258
-    * has been registered.
259
-    * 
260
-    * @param string $name
261
-    * @return bool
262
-    */
256
+    /**
257
+     * Checks whether a parameter with the specified name 
258
+     * has been registered.
259
+     * 
260
+     * @param string $name
261
+     * @return bool
262
+     */
263 263
     public function hasRegisteredParam(string $name) : bool
264 264
     {
265 265
         return isset($this->knownParams[$name]);
266 266
     }
267 267
     
268
-   /**
269
-    * Retrieves an indexed array with accept mime types
270
-    * that the client sent, in the order of preference
271
-    * the client specified.
272
-    *
273
-    * Example:
274
-    *
275
-    * array(
276
-    *     'text/html',
277
-    *     'application/xhtml+xml',
278
-    *     'image/webp'
279
-    *     ...
280
-    * )
281
-    * 
282
-    * @return array
283
-    * @see Request::parseAcceptHeaders()
284
-    */
268
+    /**
269
+     * Retrieves an indexed array with accept mime types
270
+     * that the client sent, in the order of preference
271
+     * the client specified.
272
+     *
273
+     * Example:
274
+     *
275
+     * array(
276
+     *     'text/html',
277
+     *     'application/xhtml+xml',
278
+     *     'image/webp'
279
+     *     ...
280
+     * )
281
+     * 
282
+     * @return array
283
+     * @see Request::parseAcceptHeaders()
284
+     */
285 285
     public static function getAcceptHeaders() : array
286 286
     {
287 287
         return self::parseAcceptHeaders()->getMimeStrings();
288 288
     }
289 289
     
290
-   /**
291
-    * Returns an instance of the accept headers parser,
292
-    * to access information on the browser's accepted
293
-    * mime types.
294
-    *  
295
-    * @return Request_AcceptHeaders
296
-    * @see Request::getAcceptHeaders()
297
-    */
290
+    /**
291
+     * Returns an instance of the accept headers parser,
292
+     * to access information on the browser's accepted
293
+     * mime types.
294
+     *  
295
+     * @return Request_AcceptHeaders
296
+     * @see Request::getAcceptHeaders()
297
+     */
298 298
     public static function parseAcceptHeaders() : Request_AcceptHeaders
299 299
     {
300 300
         static $accept;
@@ -342,14 +342,14 @@  discard block
 block discarded – undo
342 342
         return false;
343 343
     }
344 344
     
345
-   /**
346
-    * Removes a single parameter from the request.
347
-    * If the parameter has been registered, also
348
-    * removes the registration info.
349
-    * 
350
-    * @param string $name
351
-    * @return Request
352
-    */
345
+    /**
346
+     * Removes a single parameter from the request.
347
+     * If the parameter has been registered, also
348
+     * removes the registration info.
349
+     * 
350
+     * @param string $name
351
+     * @return Request
352
+     */
353 353
     public function removeParam(string $name) : Request
354 354
     {
355 355
         if(isset($_REQUEST[$name])) {
@@ -363,12 +363,12 @@  discard block
 block discarded – undo
363 363
         return $this;
364 364
     }
365 365
     
366
-   /**
367
-    * Removes several parameters from the request.
368
-    * 
369
-    * @param string[] $names
370
-    * @return Request
371
-    */
366
+    /**
367
+     * Removes several parameters from the request.
368
+     * 
369
+     * @param string[] $names
370
+     * @return Request
371
+     */
372 372
     public function removeParams(array $names) : Request
373 373
     {
374 374
         foreach($names as $name) {
@@ -435,18 +435,18 @@  discard block
 block discarded – undo
435 435
         return $val;
436 436
     }
437 437
     
438
-   /**
439
-    * Treats the request parameter as a JSON string, and
440
-    * if it exists and contains valid JSON, returns the
441
-    * decoded JSON value as an array (default).
442
-    *
443
-    * @param string $name
444
-    * @param bool $assoc
445
-    * @return array|object
446
-    * 
447
-    * @see Request::getJSONAssoc()
448
-    * @see Request::getJSONObject()
449
-    */
438
+    /**
439
+     * Treats the request parameter as a JSON string, and
440
+     * if it exists and contains valid JSON, returns the
441
+     * decoded JSON value as an array (default).
442
+     *
443
+     * @param string $name
444
+     * @param bool $assoc
445
+     * @return array|object
446
+     * 
447
+     * @see Request::getJSONAssoc()
448
+     * @see Request::getJSONObject()
449
+     */
450 450
     public function getJSON(string $name, bool $assoc=true)
451 451
     {
452 452
         $value = $this->getParam($name);
@@ -471,13 +471,13 @@  discard block
 block discarded – undo
471 471
         return new \stdClass();
472 472
     }
473 473
     
474
-   /**
475
-    * Like {@link Request::getJSON()}, but omitting the second
476
-    * parameter. Use this for more readable code.
477
-    * 
478
-    * @param string $name
479
-    * @return array
480
-    */
474
+    /**
475
+     * Like {@link Request::getJSON()}, but omitting the second
476
+     * parameter. Use this for more readable code.
477
+     * 
478
+     * @param string $name
479
+     * @return array
480
+     */
481 481
     public function getJSONAssoc(string $name) : array
482 482
     {
483 483
         $result = $this->getJSON($name);
@@ -488,13 +488,13 @@  discard block
 block discarded – undo
488 488
         return array();
489 489
     }
490 490
     
491
-   /**
492
-    * Like {@link Request::getJSON()}, but omitting the second
493
-    * parameter. Use this for more readable code.
494
-    *
495
-    * @param string $name
496
-    * @return object
497
-    */
491
+    /**
492
+     * Like {@link Request::getJSON()}, but omitting the second
493
+     * parameter. Use this for more readable code.
494
+     *
495
+     * @param string $name
496
+     * @return object
497
+     */
498 498
     public function getJSONObject(string $name) : object
499 499
     {
500 500
         $result = $this->getJSON($name, false);
@@ -505,12 +505,12 @@  discard block
 block discarded – undo
505 505
         return new \stdClass();
506 506
     }
507 507
     
508
-   /**
509
-    * Sends a JSON response with the correct headers.
510
-    *
511
-    * @param array|string $data
512
-    * @param bool $exit Whether to exit the script afterwards.
513
-    */
508
+    /**
509
+     * Sends a JSON response with the correct headers.
510
+     *
511
+     * @param array|string $data
512
+     * @param bool $exit Whether to exit the script afterwards.
513
+     */
514 514
     public static function sendJSON($data, bool $exit=true)
515 515
     {
516 516
         $payload = $data;
@@ -530,12 +530,12 @@  discard block
 block discarded – undo
530 530
         }
531 531
     }
532 532
     
533
-   /**
534
-    * Sends HTML to the browser with the correct headers.
535
-    * 
536
-    * @param string $html
537
-    * @param bool $exit Whether to exit the script afterwards.
538
-    */
533
+    /**
534
+     * Sends HTML to the browser with the correct headers.
535
+     * 
536
+     * @param string $html
537
+     * @param bool $exit Whether to exit the script afterwards.
538
+     */
539 539
     public static function sendHTML(string $html, bool $exit=true)
540 540
     {
541 541
         header('Cache-Control: no-cache, must-revalidate');
@@ -550,16 +550,16 @@  discard block
 block discarded – undo
550 550
         }
551 551
     }
552 552
     
553
-   /**
554
-    * Creates a new instance of the URL comparer, which can check 
555
-    * whether the specified URLs match, regardless of the order in 
556
-    * which the query parameters are, if any.
557
-    * 
558
-    * @param string $sourceURL
559
-    * @param string $targetURL
560
-    * @param array $limitParams Whether to limit the comparison to these specific parameter names (if present)
561
-    * @return Request_URLComparer
562
-    */
553
+    /**
554
+     * Creates a new instance of the URL comparer, which can check 
555
+     * whether the specified URLs match, regardless of the order in 
556
+     * which the query parameters are, if any.
557
+     * 
558
+     * @param string $sourceURL
559
+     * @param string $targetURL
560
+     * @param array $limitParams Whether to limit the comparison to these specific parameter names (if present)
561
+     * @return Request_URLComparer
562
+     */
563 563
     public function createURLComparer(string $sourceURL, string $targetURL, array $limitParams=array()) : Request_URLComparer
564 564
     {
565 565
         $comparer = new Request_URLComparer($this, $sourceURL, $targetURL);
@@ -568,10 +568,10 @@  discard block
 block discarded – undo
568 568
         return $comparer;
569 569
     }
570 570
     
571
-   /**
572
-    * Retrieves the full URL that was used to access the current page.
573
-    * @return string
574
-    */
571
+    /**
572
+     * Retrieves the full URL that was used to access the current page.
573
+     * @return string
574
+     */
575 575
     public function getCurrentURL() : string
576 576
     {
577 577
         return $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
Please login to merge, or discard this patch.
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -90,11 +90,11 @@  discard block
 block discarded – undo
90 90
     public function getParam($name, $default = null)
91 91
     {
92 92
         $value = $default;
93
-        if(isset($_REQUEST[$name])) {
93
+        if (isset($_REQUEST[$name])) {
94 94
             $value = $_REQUEST[$name];
95 95
         }
96 96
         
97
-        if(isset($this->knownParams[$name])) {
97
+        if (isset($this->knownParams[$name])) {
98 98
             $value = $this->knownParams[$name]->validate($value);
99 99
         }
100 100
         
@@ -185,13 +185,13 @@  discard block
 block discarded – undo
185 185
      * @param string $dispatcher Relative path to script to use for the URL. Append trailing slash if needed.
186 186
      * @return string
187 187
      */
188
-    public function buildURL($params = array(), string $dispatcher='')
188
+    public function buildURL($params = array(), string $dispatcher = '')
189 189
     {
190
-        $url = rtrim($this->getBaseURL(), '/') . '/' . $dispatcher;
190
+        $url = rtrim($this->getBaseURL(), '/').'/'.$dispatcher;
191 191
         
192 192
         // append any leftover parameters to the end of the URL
193 193
         if (!empty($params)) {
194
-            $url .= '?' . http_build_query($params, '', '&amp;');
194
+            $url .= '?'.http_build_query($params, '', '&amp;');
195 195
         }
196 196
         
197 197
         return $url;
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
      */
223 223
     public function registerParam($name)
224 224
     {
225
-        if(!isset($this->knownParams[$name])) {
225
+        if (!isset($this->knownParams[$name])) {
226 226
             $param = new Request_Param($this, $name);
227 227
             $this->knownParams[$name] = $param;
228 228
         }
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
     */
240 240
     public function getRegisteredParam(string $name) : Request_Param
241 241
     {
242
-        if(isset($this->knownParams[$name])) {
242
+        if (isset($this->knownParams[$name])) {
243 243
             return $this->knownParams[$name];
244 244
         }
245 245
         
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
     {
300 300
         static $accept;
301 301
         
302
-        if(!isset($accept)) {
302
+        if (!isset($accept)) {
303 303
             $accept = new Request_AcceptHeaders();
304 304
         }
305 305
         
@@ -318,7 +318,7 @@  discard block
 block discarded – undo
318 318
     {
319 319
         $_REQUEST[$name] = $value;
320 320
         
321
-        if(isset($this->knownParams[$name])) {
321
+        if (isset($this->knownParams[$name])) {
322 322
             unset($this->knownParams[$name]);
323 323
         }
324 324
         
@@ -352,11 +352,11 @@  discard block
 block discarded – undo
352 352
     */
353 353
     public function removeParam(string $name) : Request
354 354
     {
355
-        if(isset($_REQUEST[$name])) {
355
+        if (isset($_REQUEST[$name])) {
356 356
             unset($_REQUEST[$name]);
357 357
         }
358 358
         
359
-        if(isset($this->knownParams[$name])) {
359
+        if (isset($this->knownParams[$name])) {
360 360
             unset($this->knownParams[$name]);
361 361
         }
362 362
         
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
     */
372 372
     public function removeParams(array $names) : Request
373 373
     {
374
-        foreach($names as $name) {
374
+        foreach ($names as $name) {
375 375
             $this->removeParam($name);
376 376
         }
377 377
         
@@ -387,10 +387,10 @@  discard block
 block discarded – undo
387 387
      * @param string $name
388 388
      * @return bool
389 389
      */
390
-    public function getBool($name, $default=false)
390
+    public function getBool($name, $default = false)
391 391
     {
392 392
         $value = $this->getParam($name, $default);
393
-        if(ConvertHelper::isBoolean($value)) {
393
+        if (ConvertHelper::isBoolean($value)) {
394 394
             return ConvertHelper::string2bool($value);
395 395
         }
396 396
         
@@ -399,11 +399,11 @@  discard block
 block discarded – undo
399 399
     
400 400
     public function validate()
401 401
     {
402
-        foreach($this->knownParams as $param) 
402
+        foreach ($this->knownParams as $param) 
403 403
         {
404 404
             $name = $param->getName();
405 405
             
406
-            if($param->isRequired() && !$this->hasParam($name)) 
406
+            if ($param->isRequired() && !$this->hasParam($name)) 
407 407
             {
408 408
                 throw new Request_Exception(
409 409
                     'Missing request parameter '.$name,
@@ -425,10 +425,10 @@  discard block
 block discarded – undo
425 425
      * @param mixed $default
426 426
      * @return string
427 427
      */
428
-    public function getFilteredParam($name, $default=null)
428
+    public function getFilteredParam($name, $default = null)
429 429
     {
430 430
         $val = $this->getParam($name, $default);
431
-        if(is_string($val)) {
431
+        if (is_string($val)) {
432 432
             $val = htmlspecialchars(trim(strip_tags($val)), ENT_QUOTES, 'UTF-8');
433 433
         }
434 434
         
@@ -447,24 +447,24 @@  discard block
 block discarded – undo
447 447
     * @see Request::getJSONAssoc()
448 448
     * @see Request::getJSONObject()
449 449
     */
450
-    public function getJSON(string $name, bool $assoc=true)
450
+    public function getJSON(string $name, bool $assoc = true)
451 451
     {
452 452
         $value = $this->getParam($name);
453 453
         
454
-        if(!empty($value) && is_string($value)) 
454
+        if (!empty($value) && is_string($value)) 
455 455
         {
456 456
             $data = json_decode($value, $assoc);
457 457
             
458
-            if($assoc && is_array($data)) {
458
+            if ($assoc && is_array($data)) {
459 459
                 return $data;
460 460
             }
461 461
             
462
-            if(is_object($data)) {
462
+            if (is_object($data)) {
463 463
                 return $data;
464 464
             }
465 465
         }
466 466
         
467
-        if($assoc) {
467
+        if ($assoc) {
468 468
             return array();
469 469
         }
470 470
         
@@ -481,7 +481,7 @@  discard block
 block discarded – undo
481 481
     public function getJSONAssoc(string $name) : array
482 482
     {
483 483
         $result = $this->getJSON($name);
484
-        if(is_array($result)) {
484
+        if (is_array($result)) {
485 485
             return $result;
486 486
         }
487 487
         
@@ -498,7 +498,7 @@  discard block
 block discarded – undo
498 498
     public function getJSONObject(string $name) : object
499 499
     {
500 500
         $result = $this->getJSON($name, false);
501
-        if(is_object($result)) {
501
+        if (is_object($result)) {
502 502
             return $result;
503 503
         }
504 504
         
@@ -511,10 +511,10 @@  discard block
 block discarded – undo
511 511
     * @param array|string $data
512 512
     * @param bool $exit Whether to exit the script afterwards.
513 513
     */
514
-    public static function sendJSON($data, bool $exit=true)
514
+    public static function sendJSON($data, bool $exit = true)
515 515
     {
516 516
         $payload = $data;
517
-        if(!is_string($payload)) {
517
+        if (!is_string($payload)) {
518 518
             $payload = json_encode($payload);
519 519
         }
520 520
         
@@ -524,7 +524,7 @@  discard block
 block discarded – undo
524 524
         
525 525
         echo $payload;
526 526
         
527
-        if($exit) 
527
+        if ($exit) 
528 528
         {
529 529
             exit;
530 530
         }
@@ -536,7 +536,7 @@  discard block
 block discarded – undo
536 536
     * @param string $html
537 537
     * @param bool $exit Whether to exit the script afterwards.
538 538
     */
539
-    public static function sendHTML(string $html, bool $exit=true)
539
+    public static function sendHTML(string $html, bool $exit = true)
540 540
     {
541 541
         header('Cache-Control: no-cache, must-revalidate');
542 542
         header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
@@ -544,7 +544,7 @@  discard block
 block discarded – undo
544 544
         
545 545
         echo $html;
546 546
         
547
-        if($exit)
547
+        if ($exit)
548 548
         {
549 549
             exit;
550 550
         }
@@ -560,7 +560,7 @@  discard block
 block discarded – undo
560 560
     * @param array $limitParams Whether to limit the comparison to these specific parameter names (if present)
561 561
     * @return Request_URLComparer
562 562
     */
563
-    public function createURLComparer(string $sourceURL, string $targetURL, array $limitParams=array()) : Request_URLComparer
563
+    public function createURLComparer(string $sourceURL, string $targetURL, array $limitParams = array()) : Request_URLComparer
564 564
     {
565 565
         $comparer = new Request_URLComparer($this, $sourceURL, $targetURL);
566 566
         $comparer->addLimitParams($limitParams);
Please login to merge, or discard this patch.
src/Request/RefreshParams/Exclude/Name.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -19,9 +19,9 @@
 block discarded – undo
19 19
  */
20 20
 class Request_RefreshParams_Exclude_Name extends Request_RefreshParams_Exclude
21 21
 {
22
-   /**
23
-    * @var string
24
-    */
22
+    /**
23
+     * @var string
24
+     */
25 25
     private $name;
26 26
     
27 27
     public function __construct(string $paramName)
Please login to merge, or discard this patch.
src/Request/RefreshParams/Exclude/Callback.php 2 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -22,9 +22,9 @@
 block discarded – undo
22 22
 {
23 23
     const ERROR_INVALID_CALLBACK = 62101;
24 24
     
25
-   /**
26
-    * @var callable
27
-    */
25
+    /**
26
+     * @var callable
27
+     */
28 28
     private $callback;
29 29
     
30 30
     public function __construct($callback)
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@
 block discarded – undo
29 29
     
30 30
     public function __construct($callback)
31 31
     {
32
-        if(!is_callable($callback))
32
+        if (!is_callable($callback))
33 33
         {
34 34
             throw new Request_Exception(
35 35
                 'Invalid exclusion callback',
Please login to merge, or discard this patch.
src/Request/RefreshParams.php 2 patches
Indentation   +96 added lines, -96 removed lines patch added patch discarded remove patch
@@ -23,14 +23,14 @@  discard block
 block discarded – undo
23 23
 {
24 24
     use Traits_Optionable;
25 25
     
26
-   /**
27
-    * @var array<string,mixed>
28
-    */
26
+    /**
27
+     * @var array<string,mixed>
28
+     */
29 29
     private $overrides = array();
30 30
     
31
-   /**
32
-    * @var Request_RefreshParams_Exclude[]
33
-    */
31
+    /**
32
+     * @var Request_RefreshParams_Exclude[]
33
+     */
34 34
     private $excludes = array();
35 35
     
36 36
     public function getDefaultOptions() : array
@@ -41,27 +41,27 @@  discard block
 block discarded – undo
41 41
         );
42 42
     }
43 43
     
44
-   /**
45
-    * Whether to automatically exclude the session variable
46
-    * from the parameters.
47
-    * 
48
-    * @param bool $exclude
49
-    * @return Request_RefreshParams
50
-    */
44
+    /**
45
+     * Whether to automatically exclude the session variable
46
+     * from the parameters.
47
+     * 
48
+     * @param bool $exclude
49
+     * @return Request_RefreshParams
50
+     */
51 51
     public function setExcludeSessionName(bool $exclude=true) : Request_RefreshParams
52 52
     {
53 53
         $this->setOption('exclude-session-name', $exclude);
54 54
         return $this;
55 55
     }
56 56
     
57
-   /**
58
-    * Whether to automatically exclude the HTML_QuickForm2
59
-    * request variable used to track whether a form has been
60
-    * submitted.
61
-    * 
62
-    * @param bool $exclude
63
-    * @return Request_RefreshParams
64
-    */
57
+    /**
58
+     * Whether to automatically exclude the HTML_QuickForm2
59
+     * request variable used to track whether a form has been
60
+     * submitted.
61
+     * 
62
+     * @param bool $exclude
63
+     * @return Request_RefreshParams
64
+     */
65 65
     public function setExcludeQuickform(bool $exclude) : Request_RefreshParams
66 66
     {
67 67
         $this->setOption('exclude-quickform-submitter', $exclude);
@@ -78,20 +78,20 @@  discard block
 block discarded – undo
78 78
         return $this;
79 79
     }
80 80
     
81
-   /**
82
-    * Exclude a request using a callback function.
83
-    * 
84
-    * The function gets two parameters:
85
-    * 
86
-    * - The name of the request parameter
87
-    * - The value of the request parameter
88
-    * 
89
-    * If the callback returns a boolean true, the
90
-    * parameter will be excluded.
91
-    * 
92
-    * @param callable $callback
93
-    * @return Request_RefreshParams
94
-    */
81
+    /**
82
+     * Exclude a request using a callback function.
83
+     * 
84
+     * The function gets two parameters:
85
+     * 
86
+     * - The name of the request parameter
87
+     * - The value of the request parameter
88
+     * 
89
+     * If the callback returns a boolean true, the
90
+     * parameter will be excluded.
91
+     * 
92
+     * @param callable $callback
93
+     * @return Request_RefreshParams
94
+     */
95 95
     public function excludeParamByCallback($callback) : Request_RefreshParams
96 96
     {
97 97
         $this->excludes[] = new Request_RefreshParams_Exclude_Callback($callback);
@@ -99,12 +99,12 @@  discard block
 block discarded – undo
99 99
         return $this;
100 100
     }
101 101
     
102
-   /**
103
-    * Excludes a request parameter by name.
104
-    * 
105
-    * @param array $paramNames
106
-    * @return Request_RefreshParams
107
-    */
102
+    /**
103
+     * Excludes a request parameter by name.
104
+     * 
105
+     * @param array $paramNames
106
+     * @return Request_RefreshParams
107
+     */
108 108
     public function excludeParamsByName(array $paramNames) : Request_RefreshParams
109 109
     {
110 110
         foreach($paramNames as $name)
@@ -115,15 +115,15 @@  discard block
 block discarded – undo
115 115
         return $this;
116 116
     }
117 117
     
118
-   /**
119
-    * Overrides a parameter: even if it exists, this
120
-    * value will be used instead - even if it is on 
121
-    * the list of excluded parameters.
122
-    * 
123
-    * @param string $paramName
124
-    * @param mixed $paramValue
125
-    * @return Request_RefreshParams
126
-    */
118
+    /**
119
+     * Overrides a parameter: even if it exists, this
120
+     * value will be used instead - even if it is on 
121
+     * the list of excluded parameters.
122
+     * 
123
+     * @param string $paramName
124
+     * @param mixed $paramValue
125
+     * @return Request_RefreshParams
126
+     */
127 127
     public function overrideParam(string $paramName, $paramValue) : Request_RefreshParams
128 128
     {
129 129
         $this->overrides[$paramName] = $paramValue;
@@ -131,12 +131,12 @@  discard block
 block discarded – undo
131 131
         return $this;
132 132
     }
133 133
     
134
-   /**
135
-    * Overrides an array of parameters. 
136
-    * 
137
-    * @param array $params
138
-    * @return Request_RefreshParams
139
-    */
134
+    /**
135
+     * Overrides an array of parameters. 
136
+     * 
137
+     * @param array $params
138
+     * @return Request_RefreshParams
139
+     */
140 140
     public function overrideParams(array $params) : Request_RefreshParams
141 141
     {
142 142
         foreach($params as $name => $value)
@@ -147,14 +147,14 @@  discard block
 block discarded – undo
147 147
         return $this;
148 148
     }
149 149
     
150
-   /**
151
-    * Resolves all the parameter exclusions that should
152
-    * be applied to the list of parameters. This includes
153
-    * the manually added exclusions and the dynamic exclusions
154
-    * like the session name.
155
-    * 
156
-    * @return Request_RefreshParams_Exclude[]
157
-    */
150
+    /**
151
+     * Resolves all the parameter exclusions that should
152
+     * be applied to the list of parameters. This includes
153
+     * the manually added exclusions and the dynamic exclusions
154
+     * like the session name.
155
+     * 
156
+     * @return Request_RefreshParams_Exclude[]
157
+     */
158 158
     private function resolveExcludes() : array
159 159
     {
160 160
         $excludes = $this->excludes;
@@ -165,12 +165,12 @@  discard block
 block discarded – undo
165 165
         return $excludes;
166 166
     }
167 167
     
168
-   /**
169
-    * Automatically excludes the session name from the
170
-    * parameters, if present.
171
-    * 
172
-    * @param Request_RefreshParams_Exclude[] $excludes
173
-    */
168
+    /**
169
+     * Automatically excludes the session name from the
170
+     * parameters, if present.
171
+     * 
172
+     * @param Request_RefreshParams_Exclude[] $excludes
173
+     */
174 174
     private function autoExcludeSessionName(array &$excludes) : void
175 175
     {
176 176
         if($this->getBoolOption('exclude-session-name'))
@@ -179,12 +179,12 @@  discard block
 block discarded – undo
179 179
         }
180 180
     }
181 181
    
182
-   /**
183
-    * Automatically excludes the HTML_QuickForm2 submit
184
-    * tracking variable, when enabled.
185
-    * 
186
-    * @param Request_RefreshParams_Exclude[] $excludes
187
-    */
182
+    /**
183
+     * Automatically excludes the HTML_QuickForm2 submit
184
+     * tracking variable, when enabled.
185
+     * 
186
+     * @param Request_RefreshParams_Exclude[] $excludes
187
+     */
188 188
     private function autoExcludeQuickform(array &$excludes) : void
189 189
     {
190 190
         if($this->getBoolOption('exclude-quickform-submitter'))
@@ -196,12 +196,12 @@  discard block
 block discarded – undo
196 196
         }
197 197
     }
198 198
     
199
-   /**
200
-    * Retrieves the list of parameters matching the 
201
-    * current settings.
202
-    * 
203
-    * @return array<string,mixed>
204
-    */
199
+    /**
200
+     * Retrieves the list of parameters matching the 
201
+     * current settings.
202
+     * 
203
+     * @return array<string,mixed>
204
+     */
205 205
     public function getParams() : array
206 206
     {
207 207
         $params = $this->removeExcluded($_REQUEST);
@@ -217,12 +217,12 @@  discard block
 block discarded – undo
217 217
         return $params;
218 218
     }
219 219
     
220
-   /**
221
-    * Removes all excluded parameters from the array.
222
-    * 
223
-    * @param array<string,mixed> $params
224
-    * @return array<string,mixed>
225
-    */
220
+    /**
221
+     * Removes all excluded parameters from the array.
222
+     * 
223
+     * @param array<string,mixed> $params
224
+     * @return array<string,mixed>
225
+     */
226 226
     private function removeExcluded(array $params) : array
227 227
     {
228 228
         $result = array();
@@ -240,14 +240,14 @@  discard block
 block discarded – undo
240 240
         return $result;
241 241
     }
242 242
     
243
-   /**
244
-    * Checks all configured exclusions to see if the 
245
-    * parameter should be excluded or not.
246
-    * 
247
-    * @param string $paramName
248
-    * @param mixed $paramValue
249
-    * @return bool
250
-    */
243
+    /**
244
+     * Checks all configured exclusions to see if the 
245
+     * parameter should be excluded or not.
246
+     * 
247
+     * @param string $paramName
248
+     * @param mixed $paramValue
249
+     * @return bool
250
+     */
251 251
     public function isExcluded(string $paramName, $paramValue) : bool
252 252
     {
253 253
         $excludes = $this->resolveExcludes();
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
     * @param bool $exclude
49 49
     * @return Request_RefreshParams
50 50
     */
51
-    public function setExcludeSessionName(bool $exclude=true) : Request_RefreshParams
51
+    public function setExcludeSessionName(bool $exclude = true) : Request_RefreshParams
52 52
     {
53 53
         $this->setOption('exclude-session-name', $exclude);
54 54
         return $this;
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
     
71 71
     public function excludeParamByName(string $paramName) : Request_RefreshParams
72 72
     {
73
-        if($paramName !== '')
73
+        if ($paramName !== '')
74 74
         {
75 75
             $this->excludes[] = new Request_RefreshParams_Exclude_Name($paramName);
76 76
         }
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
     */
108 108
     public function excludeParamsByName(array $paramNames) : Request_RefreshParams
109 109
     {
110
-        foreach($paramNames as $name)
110
+        foreach ($paramNames as $name)
111 111
         {
112 112
             $this->excludeParamByName((string)$name);
113 113
         }
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
     */
140 140
     public function overrideParams(array $params) : Request_RefreshParams
141 141
     {
142
-        foreach($params as $name => $value)
142
+        foreach ($params as $name => $value)
143 143
         {
144 144
             $this->overrideParam((string)$name, $value);
145 145
         }
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
     */
174 174
     private function autoExcludeSessionName(array &$excludes) : void
175 175
     {
176
-        if($this->getBoolOption('exclude-session-name'))
176
+        if ($this->getBoolOption('exclude-session-name'))
177 177
         {
178 178
             $excludes[] = new Request_RefreshParams_Exclude_Name(session_name());
179 179
         }
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
     */
188 188
     private function autoExcludeQuickform(array &$excludes) : void
189 189
     {
190
-        if($this->getBoolOption('exclude-quickform-submitter'))
190
+        if ($this->getBoolOption('exclude-quickform-submitter'))
191 191
         {
192 192
             $excludes[] = new Request_RefreshParams_Exclude_Callback(function(string $paramName)
193 193
             {
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
         // Note: using this loop instead of array_merge,
210 210
         // because array_merge has weird behavior when
211 211
         // using numeric keys.
212
-        foreach($this->overrides as $name => $val)
212
+        foreach ($this->overrides as $name => $val)
213 213
         {
214 214
             $params[$name] = $val;
215 215
         }
@@ -227,11 +227,11 @@  discard block
 block discarded – undo
227 227
     {
228 228
         $result = array();
229 229
         
230
-        foreach($params as $name => $value)
230
+        foreach ($params as $name => $value)
231 231
         {
232 232
             $name = (string)$name;
233 233
             
234
-            if(!$this->isExcluded($name, $value))
234
+            if (!$this->isExcluded($name, $value))
235 235
             {
236 236
                 $result[$name] = $value;
237 237
             }
@@ -252,9 +252,9 @@  discard block
 block discarded – undo
252 252
     {
253 253
         $excludes = $this->resolveExcludes();
254 254
         
255
-        foreach($excludes as $exclude)
255
+        foreach ($excludes as $exclude)
256 256
         {
257
-            if($exclude->isExcluded($paramName, $paramValue))
257
+            if ($exclude->isExcluded($paramName, $paramValue))
258 258
             {
259 259
                 return true;
260 260
             }
Please login to merge, or discard this patch.
src/RequestHelper.php 3 patches
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
 
242 242
         $output = curl_exec($ch);
243 243
 
244
-        if(isset($this->logfilePointer))
244
+        if (isset($this->logfilePointer))
245 245
         {
246 246
             fclose($this->logfilePointer);
247 247
         }
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
         // CURL will complain about an empty response when the 
254 254
         // server sends a 100-continue code. That should not be
255 255
         // regarded as an error.
256
-        if($output === false && $this->response->getCode() !== 100)
256
+        if ($output === false && $this->response->getCode() !== 100)
257 257
         {
258 258
             $curlCode = curl_errno($ch);
259 259
             
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
     {
290 290
         $ch = curl_init();
291 291
         
292
-        if(!is_resource($ch))
292
+        if (!is_resource($ch))
293 293
         {
294 294
             throw new RequestHelper_Exception(
295 295
                 'Could not initialize a new cURL instance.',
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
         }
300 300
 
301 301
         $this->setHeader('Content-Length', (string)$this->boundaries->getContentLength());
302
-        $this->setHeader('Content-Type', 'multipart/form-data; boundary=' . $this->mimeBoundary);
302
+        $this->setHeader('Content-Type', 'multipart/form-data; boundary='.$this->mimeBoundary);
303 303
 
304 304
         curl_setopt($ch, CURLOPT_POST, true);
305 305
         curl_setopt($ch, CURLOPT_URL, $url->getNormalizedWithoutAuth());
@@ -312,18 +312,18 @@  discard block
 block discarded – undo
312 312
         
313 313
         $loggingEnabled = $this->configureLogging($ch);
314 314
         
315
-        if(!$loggingEnabled) 
315
+        if (!$loggingEnabled) 
316 316
         {
317 317
             curl_setopt($ch, CURLINFO_HEADER_OUT, true);
318 318
         }
319 319
         
320
-        if($this->verifySSL)
320
+        if ($this->verifySSL)
321 321
         {
322 322
             curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
323 323
             curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
324 324
         }
325 325
         
326
-        if($url->hasUsername())
326
+        if ($url->hasUsername())
327 327
         {
328 328
             curl_setopt($ch, CURLOPT_USERNAME, $url->getUsername());
329 329
             curl_setopt($ch, CURLOPT_PASSWORD, $url->getPassword());
@@ -338,14 +338,14 @@  discard block
 block discarded – undo
338 338
     */
339 339
     protected function configureLogging($ch) : bool
340 340
     {
341
-        if(empty($this->logfile))
341
+        if (empty($this->logfile))
342 342
         {
343 343
             return false;
344 344
         }
345 345
         
346 346
         $res = fopen($this->logfile, 'w+');
347 347
         
348
-        if($res === false)
348
+        if ($res === false)
349 349
         {
350 350
             throw new RequestHelper_Exception(
351 351
                 'Cannot open logfile for writing.',
@@ -375,7 +375,7 @@  discard block
 block discarded – undo
375 375
         
376 376
         $this->setHeader('Expect', '');
377 377
         
378
-        foreach($this->headers as $name => $value) {
378
+        foreach ($this->headers as $name => $value) {
379 379
             $result[] = $name.': '.$value;
380 380
         }
381 381
         
@@ -392,7 +392,7 @@  discard block
 block discarded – undo
392 392
     {
393 393
         $response = $this->getResponse();
394 394
         
395
-        if($response !== null) {
395
+        if ($response !== null) {
396 396
             return $response->getHeaders();
397 397
         }
398 398
 
@@ -428,7 +428,7 @@  discard block
 block discarded – undo
428 428
     */
429 429
     public function getHeader(string $name) : string
430 430
     {
431
-        if(isset($this->headers[$name]))
431
+        if (isset($this->headers[$name]))
432 432
         {
433 433
             return $this->headers[$name];
434 434
         }
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -261,8 +261,7 @@
 block discarded – undo
261 261
                 $curlCode,
262 262
                 curl_error($ch).' | Explanation: '.curl_strerror($curlCode)
263 263
             );
264
-        }
265
-        else
264
+        } else
266 265
         {
267 266
             $this->response->setBody((string)$output);
268 267
         }
Please login to merge, or discard this patch.
Indentation   +151 added lines, -151 removed lines patch added patch discarded remove patch
@@ -32,62 +32,62 @@  discard block
 block discarded – undo
32 32
     const ERROR_CURL_INIT_FAILED = 17903;
33 33
     const ERROR_CANNOT_OPEN_LOGFILE = 17904;
34 34
 
35
-   /**
36
-    * @var string
37
-    */
35
+    /**
36
+     * @var string
37
+     */
38 38
     protected $eol = "\r\n";
39 39
 
40
-   /**
41
-    * @var string
42
-    */
40
+    /**
41
+     * @var string
42
+     */
43 43
     protected $mimeBoundary;
44 44
 
45
-   /**
46
-    * @var string
47
-    */
45
+    /**
46
+     * @var string
47
+     */
48 48
     protected $destination;
49 49
 
50
-   /**
51
-    * @var array<string,string>
52
-    */
50
+    /**
51
+     * @var array<string,string>
52
+     */
53 53
     protected $headers = array();
54 54
     
55
-   /**
56
-    * Whether to verify SSL certificates.
57
-    * @var bool
58
-    */
55
+    /**
56
+     * Whether to verify SSL certificates.
57
+     * @var bool
58
+     */
59 59
     protected $verifySSL = true;
60 60
     
61
-   /**
62
-    * @var RequestHelper_Boundaries
63
-    */
61
+    /**
62
+     * @var RequestHelper_Boundaries
63
+     */
64 64
     protected $boundaries;
65 65
     
66
-   /**
67
-    * @var RequestHelper_Response|NULL
68
-    */
66
+    /**
67
+     * @var RequestHelper_Response|NULL
68
+     */
69 69
     protected $response;
70 70
 
71
-   /**
72
-    * Timeout duration, in seconds.
73
-    * @var integer
74
-    */
71
+    /**
72
+     * Timeout duration, in seconds.
73
+     * @var integer
74
+     */
75 75
     protected $timeout = 30;
76 76
     
77
-   /**
78
-    * @var string
79
-    */
77
+    /**
78
+     * @var string
79
+     */
80 80
     protected $logfile = '';
81 81
 
82
-   /**
83
-    * @var resource|NULL
84
-    */
82
+    /**
83
+     * @var resource|NULL
84
+     */
85 85
     protected $logfilePointer = null;
86 86
     
87
-   /**
88
-    * Creates a new request helper to send POST data to the specified destination URL.
89
-    * @param string $destinationURL
90
-    */
87
+    /**
88
+     * Creates a new request helper to send POST data to the specified destination URL.
89
+     * @param string $destinationURL
90
+     */
91 91
     public function __construct(string $destinationURL)
92 92
     {
93 93
         $this->destination = $destinationURL;
@@ -112,13 +112,13 @@  discard block
 block discarded – undo
112 112
         return $this->eol;
113 113
     }
114 114
     
115
-   /**
116
-    * Sets the timeout for the request, in seconds. If the request
117
-    * takes longer, it will be cancelled and an exception triggered.
118
-    * 
119
-    * @param int $seconds
120
-    * @return RequestHelper
121
-    */
115
+    /**
116
+     * Sets the timeout for the request, in seconds. If the request
117
+     * takes longer, it will be cancelled and an exception triggered.
118
+     * 
119
+     * @param int $seconds
120
+     * @return RequestHelper
121
+     */
122 122
     public function setTimeout(int $seconds) : RequestHelper
123 123
     {
124 124
         $this->timeout = $seconds;
@@ -131,13 +131,13 @@  discard block
 block discarded – undo
131 131
         return $this->timeout;
132 132
     }
133 133
     
134
-   /**
135
-    * Enables verbose logging of the CURL request, which
136
-    * is then redirected to the target file.
137
-    * 
138
-    * @param string $targetFile
139
-    * @return RequestHelper
140
-    */
134
+    /**
135
+     * Enables verbose logging of the CURL request, which
136
+     * is then redirected to the target file.
137
+     * 
138
+     * @param string $targetFile
139
+     * @return RequestHelper
140
+     */
141 141
     public function enableLogging(string $targetFile) : RequestHelper
142 142
     {
143 143
         $this->logfile = $targetFile;
@@ -145,15 +145,15 @@  discard block
 block discarded – undo
145 145
         return $this;
146 146
     }
147 147
 
148
-   /**
149
-    * Adds a file to be sent with the request.
150
-    *
151
-    * @param string $varName The variable name to send the file in
152
-    * @param string $fileName The name of the file as it should be received at the destination
153
-    * @param string $content The raw content of the file
154
-    * @param string $contentType The content type, use the constants to specify this
155
-    * @param string $encoding The encoding of the file, use the constants to specify this
156
-    */
148
+    /**
149
+     * Adds a file to be sent with the request.
150
+     *
151
+     * @param string $varName The variable name to send the file in
152
+     * @param string $fileName The name of the file as it should be received at the destination
153
+     * @param string $content The raw content of the file
154
+     * @param string $contentType The content type, use the constants to specify this
155
+     * @param string $encoding The encoding of the file, use the constants to specify this
156
+     */
157 157
     public function addFile(string $varName, string $fileName, string $content, string $contentType = '', string $encoding = '') : RequestHelper
158 158
     {
159 159
         $this->boundaries->addFile($varName, $fileName, $content, $contentType, $encoding);
@@ -161,13 +161,13 @@  discard block
 block discarded – undo
161 161
         return $this;
162 162
     }
163 163
     
164
-   /**
165
-    * Adds arbitrary content.
166
-    * 
167
-    * @param string $varName The variable name to send the content in.
168
-    * @param string $content
169
-    * @param string $contentType
170
-    */
164
+    /**
165
+     * Adds arbitrary content.
166
+     * 
167
+     * @param string $varName The variable name to send the content in.
168
+     * @param string $content
169
+     * @param string $contentType
170
+     */
171 171
     public function addContent(string $varName, string $content, string $contentType) : RequestHelper
172 172
     {
173 173
         $this->boundaries->addContent($varName, $content, $contentType);
@@ -175,13 +175,13 @@  discard block
 block discarded – undo
175 175
         return $this;
176 176
     }
177 177
 
178
-   /**
179
-    * Adds a variable to be sent with the request. If it
180
-    * already exists, its value is overwritten.
181
-    *
182
-    * @param string $name
183
-    * @param string $value
184
-    */
178
+    /**
179
+     * Adds a variable to be sent with the request. If it
180
+     * already exists, its value is overwritten.
181
+     *
182
+     * @param string $name
183
+     * @param string $value
184
+     */
185 185
     public function addVariable(string $name, string $value) : RequestHelper
186 186
     {
187 187
         $this->boundaries->addVariable($name, $value);
@@ -189,13 +189,13 @@  discard block
 block discarded – undo
189 189
         return $this;
190 190
     }
191 191
     
192
-   /**
193
-    * Sets an HTTP header to include in the request.
194
-    * 
195
-    * @param string $name
196
-    * @param string $value
197
-    * @return RequestHelper
198
-    */
192
+    /**
193
+     * Sets an HTTP header to include in the request.
194
+     * 
195
+     * @param string $name
196
+     * @param string $value
197
+     * @return RequestHelper
198
+     */
199 199
     public function setHeader(string $name, string $value) : RequestHelper
200 200
     {
201 201
         $this->headers[$name] = $value;
@@ -203,36 +203,36 @@  discard block
 block discarded – undo
203 203
         return $this;
204 204
     }
205 205
     
206
-   /**
207
-    * Disables SSL certificate checking.
208
-    * 
209
-    * @return RequestHelper
210
-    */
206
+    /**
207
+     * Disables SSL certificate checking.
208
+     * 
209
+     * @return RequestHelper
210
+     */
211 211
     public function disableSSLChecks() : RequestHelper
212 212
     {
213 213
         $this->verifySSL = false;
214 214
         return $this;
215 215
     }
216 216
    
217
-   /**
218
-    * @var integer
219
-    */
217
+    /**
218
+     * @var integer
219
+     */
220 220
     protected $contentLength = 0;
221 221
 
222
-   /**
223
-    * Sends the POST request to the destination, and returns
224
-    * the response text.
225
-    *
226
-    * The response object is stored internally, so after calling
227
-    * this method it may be retrieved at any moment using the
228
-    * {@link getResponse()} method.
229
-    *
230
-    * @return string
231
-    * @see RequestHelper::getResponse()
232
-    * @throws RequestHelper_Exception
233
-    * 
234
-    * @see RequestHelper::ERROR_REQUEST_FAILED
235
-    */
222
+    /**
223
+     * Sends the POST request to the destination, and returns
224
+     * the response text.
225
+     *
226
+     * The response object is stored internally, so after calling
227
+     * this method it may be retrieved at any moment using the
228
+     * {@link getResponse()} method.
229
+     *
230
+     * @return string
231
+     * @see RequestHelper::getResponse()
232
+     * @throws RequestHelper_Exception
233
+     * 
234
+     * @see RequestHelper::ERROR_REQUEST_FAILED
235
+     */
236 236
     public function send() : string
237 237
     {
238 238
         $info = parseURL($this->destination);
@@ -272,26 +272,26 @@  discard block
 block discarded – undo
272 272
         return $this->response->getResponseBody();
273 273
     }
274 274
     
275
-   /**
276
-    * Retrieves the request's body content. This is an alias
277
-    * for {@see RequestHelper::getMimeBody()}.
278
-    * 
279
-    * @return string
280
-    * @see RequestHelper::getMimeBody()
281
-    */
275
+    /**
276
+     * Retrieves the request's body content. This is an alias
277
+     * for {@see RequestHelper::getMimeBody()}.
278
+     * 
279
+     * @return string
280
+     * @see RequestHelper::getMimeBody()
281
+     */
282 282
     public function getBody() : string
283 283
     {
284 284
         return $this->getMimeBody();
285 285
     }
286 286
     
287
-   /**
288
-    * Creates a new CURL resource configured according to the
289
-    * request's settings.
290
-    * 
291
-    * @param URLInfo $url
292
-    * @throws RequestHelper_Exception
293
-    * @return resource
294
-    */
287
+    /**
288
+     * Creates a new CURL resource configured according to the
289
+     * request's settings.
290
+     * 
291
+     * @param URLInfo $url
292
+     * @throws RequestHelper_Exception
293
+     * @return resource
294
+     */
295 295
     protected function createCURL(URLInfo $url)
296 296
     {
297 297
         $ch = curl_init();
@@ -339,10 +339,10 @@  discard block
 block discarded – undo
339 339
         return $ch;
340 340
     }
341 341
     
342
-   /**
343
-    * @param resource $ch
344
-    * @return bool Whether logging is enabled.
345
-    */
342
+    /**
343
+     * @param resource $ch
344
+     * @return bool Whether logging is enabled.
345
+     */
346 346
     protected function configureLogging($ch) : bool
347 347
     {
348 348
         if(empty($this->logfile))
@@ -369,13 +369,13 @@  discard block
 block discarded – undo
369 369
         return true;
370 370
     }
371 371
 
372
-   /**
373
-    * Compiles the associative headers array into
374
-    * the format understood by CURL, namely an indexed
375
-    * array with one header string per entry.
376
-    * 
377
-    * @return array
378
-    */
372
+    /**
373
+     * Compiles the associative headers array into
374
+     * the format understood by CURL, namely an indexed
375
+     * array with one header string per entry.
376
+     * 
377
+     * @return array
378
+     */
379 379
     protected function renderHeaders() : array
380 380
     {
381 381
         $result = array();
@@ -389,12 +389,12 @@  discard block
 block discarded – undo
389 389
         return $result;
390 390
     }
391 391
     
392
-   /**
393
-    * Retrieves the raw response header, in the form of an indexed
394
-    * array containing all response header lines.
395
-    * 
396
-    * @return array
397
-    */
392
+    /**
393
+     * Retrieves the raw response header, in the form of an indexed
394
+     * array containing all response header lines.
395
+     * 
396
+     * @return array
397
+     */
398 398
     public function getResponseHeader() : array
399 399
     {
400 400
         $response = $this->getResponse();
@@ -406,33 +406,33 @@  discard block
 block discarded – undo
406 406
         return array();
407 407
     }
408 408
 
409
-   /**
410
-    * After calling the {@link send()} method, this may be used to
411
-    * retrieve the response text from the POST request.
412
-    *
413
-    * @return RequestHelper_Response|NULL
414
-    */
409
+    /**
410
+     * After calling the {@link send()} method, this may be used to
411
+     * retrieve the response text from the POST request.
412
+     *
413
+     * @return RequestHelper_Response|NULL
414
+     */
415 415
     public function getResponse() : ?RequestHelper_Response
416 416
     {
417 417
         return $this->response;
418 418
     }
419 419
     
420
-   /**
421
-    * Retrieves all headers set until now.
422
-    * 
423
-    * @return array<string,string>
424
-    */
420
+    /**
421
+     * Retrieves all headers set until now.
422
+     * 
423
+     * @return array<string,string>
424
+     */
425 425
     public function getHeaders() : array
426 426
     {
427 427
         return $this->headers;
428 428
     }
429 429
     
430
-   /**
431
-    * Retrieves the value of a header by its name.
432
-    * 
433
-    * @param string $name
434
-    * @return string The header value, or an empty string if not set.
435
-    */
430
+    /**
431
+     * Retrieves the value of a header by its name.
432
+     * 
433
+     * @param string $name
434
+     * @return string The header value, or an empty string if not set.
435
+     */
436 436
     public function getHeader(string $name) : string
437 437
     {
438 438
         if(isset($this->headers[$name]))
Please login to merge, or discard this patch.
src/XMLHelper.php 2 patches
Indentation   +172 added lines, -172 removed lines patch added patch discarded remove patch
@@ -28,9 +28,9 @@  discard block
 block discarded – undo
28 28
 {
29 29
     const ERROR_CANNOT_APPEND_FRAGMENT = 491001; 
30 30
 
31
-   /**
32
-    * @var boolean
33
-    */
31
+    /**
32
+     * @var boolean
33
+     */
34 34
     private static $simulation = false;
35 35
 
36 36
     /**
@@ -38,11 +38,11 @@  discard block
 block discarded – undo
38 38
      */
39 39
     private $dom;
40 40
     
41
-   /**
42
-    * Creates a new XMLHelper instance.
43
-    * 
44
-    * @return XMLHelper
45
-    */
41
+    /**
42
+     * Creates a new XMLHelper instance.
43
+     * 
44
+     * @return XMLHelper
45
+     */
46 46
     public static function create() : XMLHelper
47 47
     {
48 48
         $dom = new DOMDocument('1.0', 'UTF-8');
@@ -51,72 +51,72 @@  discard block
 block discarded – undo
51 51
         return new XMLHelper($dom);
52 52
     }
53 53
     
54
-   /**
55
-    * Creates a converter instance from an XML file.
56
-    * @param string $xmlFile
57
-    * @return XMLHelper_Converter
58
-    */
54
+    /**
55
+     * Creates a converter instance from an XML file.
56
+     * @param string $xmlFile
57
+     * @return XMLHelper_Converter
58
+     */
59 59
     public static function convertFile(string $xmlFile) : XMLHelper_Converter
60 60
     {
61 61
         return XMLHelper_Converter::fromFile($xmlFile);
62 62
     }
63 63
     
64
-   /**
65
-    * Creates a converter from an XML string.
66
-    * @param string $xmlString
67
-    * @return XMLHelper_Converter
68
-    */
64
+    /**
65
+     * Creates a converter from an XML string.
66
+     * @param string $xmlString
67
+     * @return XMLHelper_Converter
68
+     */
69 69
     public static function convertString(string $xmlString) : XMLHelper_Converter
70 70
     {
71 71
         return XMLHelper_Converter::fromString($xmlString);
72 72
     }
73 73
 
74
-   /**
75
-    * Creates a converter from a SimpleXMLElement instance.
76
-    * @param SimpleXMLElement $element
77
-    * @return XMLHelper_Converter
78
-    */
74
+    /**
75
+     * Creates a converter from a SimpleXMLElement instance.
76
+     * @param SimpleXMLElement $element
77
+     * @return XMLHelper_Converter
78
+     */
79 79
     public static function convertElement(SimpleXMLElement $element) : XMLHelper_Converter
80 80
     {
81 81
         return XMLHelper_Converter::fromElement($element);
82 82
     }
83 83
    
84
-   /**
85
-    * Creates a converter from a DOMElement instance.
86
-    * @param DOMElement $element
87
-    * @return XMLHelper_Converter
88
-    */
84
+    /**
85
+     * Creates a converter from a DOMElement instance.
86
+     * @param DOMElement $element
87
+     * @return XMLHelper_Converter
88
+     */
89 89
     public static function convertDOMElement(DOMElement $element) : XMLHelper_Converter
90 90
     {
91 91
         return XMLHelper_Converter::fromDOMElement($element);
92 92
     }
93 93
 
94
-   /**
95
-    * Creates a new helper using an existing DOMDocument object.
96
-    * @param DOMDocument $dom
97
-    */
94
+    /**
95
+     * Creates a new helper using an existing DOMDocument object.
96
+     * @param DOMDocument $dom
97
+     */
98 98
     public function __construct(DOMDocument $dom)
99 99
     {
100 100
         $this->dom = $dom;
101 101
     }
102 102
 
103
-   /**
104
-    * @return DOMDocument
105
-    */
103
+    /**
104
+     * @return DOMDocument
105
+     */
106 106
     public function getDOM() : DOMDocument
107 107
     {
108 108
         return $this->dom;
109 109
     }
110 110
 
111
-   /**
112
-    * Adds an attribute to an existing tag with
113
-    * the specified value.
114
-    *
115
-    * @param DOMNode $parent
116
-    * @param string $name
117
-    * @param mixed $value
118
-    * @return DOMNode
119
-    */
111
+    /**
112
+     * Adds an attribute to an existing tag with
113
+     * the specified value.
114
+     *
115
+     * @param DOMNode $parent
116
+     * @param string $name
117
+     * @param mixed $value
118
+     * @return DOMNode
119
+     */
120 120
     public function addAttribute(DOMNode $parent, string $name, $value)
121 121
     {
122 122
         $node = $this->dom->createAttribute($name);
@@ -126,12 +126,12 @@  discard block
 block discarded – undo
126 126
         return $parent->appendChild($node);
127 127
     }
128 128
 
129
-   /**
130
-    * Adds several attributes to the target node.
131
-    * 
132
-    * @param DOMNode $parent
133
-    * @param array<string,mixed> $attributes
134
-    */
129
+    /**
130
+     * Adds several attributes to the target node.
131
+     * 
132
+     * @param DOMNode $parent
133
+     * @param array<string,mixed> $attributes
134
+     */
135 135
     public function addAttributes(DOMNode $parent, array $attributes) : void
136 136
     {
137 137
         foreach ($attributes as $name => $value) {
@@ -139,14 +139,14 @@  discard block
 block discarded – undo
139 139
         }
140 140
     }
141 141
 
142
-   /**
143
-    * Adds a tag without content.
144
-    *
145
-    * @param DOMNode $parent
146
-    * @param string $name
147
-    * @param integer $indent
148
-    * @return DOMNode
149
-    */
142
+    /**
143
+     * Adds a tag without content.
144
+     *
145
+     * @param DOMNode $parent
146
+     * @param string $name
147
+     * @param integer $indent
148
+     * @return DOMNode
149
+     */
150 150
     public function addTag(DOMNode $parent, string $name, int $indent = 0) : DOMNode
151 151
     {
152 152
         if ($indent > 0) {
@@ -168,17 +168,17 @@  discard block
 block discarded – undo
168 168
         $parent->appendChild($this->dom->createTextNode(str_repeat("\t", $amount)));
169 169
     }
170 170
 
171
-   /**
172
-    * Adds a tag with textual content, like:
173
-    *
174
-    * <tagname>text</tagname>
175
-    *
176
-    * @param DOMNode $parent
177
-    * @param string $name
178
-    * @param string $text
179
-    * @param integer $indent
180
-    * @return DOMNode
181
-    */
171
+    /**
172
+     * Adds a tag with textual content, like:
173
+     *
174
+     * <tagname>text</tagname>
175
+     *
176
+     * @param DOMNode $parent
177
+     * @param string $name
178
+     * @param string $text
179
+     * @param integer $indent
180
+     * @return DOMNode
181
+     */
182 182
     public function addTextTag(DOMNode $parent, string $name, string $text, int $indent = 0) : DOMNode
183 183
     {
184 184
         if ($indent > 0) {
@@ -192,19 +192,19 @@  discard block
 block discarded – undo
192 192
         return $parent->appendChild($tag);
193 193
     }
194 194
 
195
-   /**
196
-    * Adds a tag with textual content, like:
197
-    *
198
-    * <tagname>text</tagname>
199
-    *
200
-    * and removes <p> tags
201
-    *
202
-    * @param DOMNode $parent
203
-    * @param string $name
204
-    * @param string $text
205
-    * @param integer $indent
206
-    * @return DOMNode
207
-    */
195
+    /**
196
+     * Adds a tag with textual content, like:
197
+     *
198
+     * <tagname>text</tagname>
199
+     *
200
+     * and removes <p> tags
201
+     *
202
+     * @param DOMNode $parent
203
+     * @param string $name
204
+     * @param string $text
205
+     * @param integer $indent
206
+     * @return DOMNode
207
+     */
208 208
     public function addEscapedTag(DOMNode $parent, string $name, string $text, int $indent = 0)
209 209
     {
210 210
         if ($indent > 0) {
@@ -220,19 +220,19 @@  discard block
 block discarded – undo
220 220
         return $parent->appendChild($tag);
221 221
     }
222 222
 
223
-   /**
224
-    * Adds a tag with HTML content, like:
225
-    *
226
-    * <tagname><i>text</i></tagname>
227
-    *
228
-    * Tags will not be escaped.
229
-    *
230
-    * @param DOMNode $parent
231
-    * @param string $name
232
-    * @param string $text
233
-    * @param integer $indent
234
-    * @return DOMNode
235
-    */
223
+    /**
224
+     * Adds a tag with HTML content, like:
225
+     *
226
+     * <tagname><i>text</i></tagname>
227
+     *
228
+     * Tags will not be escaped.
229
+     *
230
+     * @param DOMNode $parent
231
+     * @param string $name
232
+     * @param string $text
233
+     * @param integer $indent
234
+     * @return DOMNode
235
+     */
236 236
     public function addFragmentTag(DOMNode $parent, string $name, string $text, int $indent = 0)
237 237
     {
238 238
         if ($indent > 0) {
@@ -260,16 +260,16 @@  discard block
 block discarded – undo
260 260
         return $parent->appendChild($tag);
261 261
     }
262 262
 
263
-   /**
264
-    * Adds a tag with CDATA content, like:
265
-    *
266
-    * <tagname><![CDATA[value]]></tagname>
267
-    *
268
-    * @param DOMNode $parent
269
-    * @param string $name
270
-    * @param string $content
271
-    * @return DOMNode
272
-    */
263
+    /**
264
+     * Adds a tag with CDATA content, like:
265
+     *
266
+     * <tagname><![CDATA[value]]></tagname>
267
+     *
268
+     * @param DOMNode $parent
269
+     * @param string $name
270
+     * @param string $content
271
+     * @return DOMNode
272
+     */
273 273
     public function addCDATATag(DOMNode $parent, string $name, string $content) : DOMNode
274 274
     {
275 275
         $tag = $this->dom->createElement($name);
@@ -279,12 +279,12 @@  discard block
 block discarded – undo
279 279
         return $parent->appendChild($tag);
280 280
     }
281 281
 
282
-   /**
283
-    * Creates the root element of the document.
284
-    * @param string $name
285
-    * @param array<string,mixed> $attributes
286
-    * @return DOMNode
287
-    */
282
+    /**
283
+     * Creates the root element of the document.
284
+     * @param string $name
285
+     * @param array<string,mixed> $attributes
286
+     * @return DOMNode
287
+     */
288 288
     public function createRoot(string $name, array $attributes=array())
289 289
     {
290 290
         $root = $this->dom->appendChild($this->dom->createElement($name));
@@ -292,12 +292,12 @@  discard block
 block discarded – undo
292 292
         return $root;
293 293
     }
294 294
 
295
-   /**
296
-    * Escaped the string for use in XML.
297
-    * 
298
-    * @param string $string
299
-    * @return string
300
-    */
295
+    /**
296
+     * Escaped the string for use in XML.
297
+     * 
298
+     * @param string $string
299
+     * @return string
300
+     */
301 301
     public function escape(string $string) : string
302 302
     {
303 303
         $string = preg_replace('#<p>(.*)</p>#isUm', '$1', $string);
@@ -317,18 +317,18 @@  discard block
 block discarded – undo
317 317
         return $string;
318 318
     }
319 319
 
320
-   /**
321
-    * Sends the specified XML string to the browser with
322
-    * the correct headers to trigger a download of the XML
323
-    * to a local file.
324
-    * 
325
-    * NOTE: Ensure calling exit after this is done, and to
326
-    * not send additional content, which would corrupt the 
327
-    * download.
328
-    *
329
-    * @param string $xml
330
-    * @param string $filename
331
-    */
320
+    /**
321
+     * Sends the specified XML string to the browser with
322
+     * the correct headers to trigger a download of the XML
323
+     * to a local file.
324
+     * 
325
+     * NOTE: Ensure calling exit after this is done, and to
326
+     * not send additional content, which would corrupt the 
327
+     * download.
328
+     *
329
+     * @param string $xml
330
+     * @param string $filename
331
+     */
332 332
     public static function downloadXML(string $xml, string $filename = 'download.xml') : void
333 333
     {
334 334
         if(!headers_sent() && !self::$simulation) 
@@ -339,12 +339,12 @@  discard block
 block discarded – undo
339 339
         echo $xml;
340 340
     }
341 341
 
342
-   /**
343
-    * Sends the specified XML string to the browser with
344
-    * the correct headers and terminates the request.
345
-    *
346
-    * @param string $xml
347
-    */
342
+    /**
343
+     * Sends the specified XML string to the browser with
344
+     * the correct headers and terminates the request.
345
+     *
346
+     * @param string $xml
347
+     */
348 348
     public static function displayXML(string $xml) : void
349 349
     {
350 350
         if(!headers_sent() && !self::$simulation) 
@@ -411,23 +411,23 @@  discard block
 block discarded – undo
411 411
         return $xml->saveXML();
412 412
     }
413 413
 
414
-   /**
415
-    * Creates XML markup to describe an application error
416
-    * when using XML services. Creates XML with the
417
-    * following structure:
418
-    *
419
-    * <error>
420
-    *     <id>99</id>
421
-    *     <message>Full error message text</message>
422
-    *     <title>Short error label</title>
423
-    * </error>
424
-    *
425
-    * @param string|number $code
426
-    * @param string $message
427
-    * @param string $title
428
-    * @param array<string,string> $customInfo
429
-    * @return string
430
-    */
414
+    /**
415
+     * Creates XML markup to describe an application error
416
+     * when using XML services. Creates XML with the
417
+     * following structure:
418
+     *
419
+     * <error>
420
+     *     <id>99</id>
421
+     *     <message>Full error message text</message>
422
+     *     <title>Short error label</title>
423
+     * </error>
424
+     *
425
+     * @param string|number $code
426
+     * @param string $message
427
+     * @param string $title
428
+     * @param array<string,string> $customInfo
429
+     * @return string
430
+     */
431 431
     public static function buildErrorXML($code, string $message, string $title, array $customInfo=array())
432 432
     {
433 433
         $xml = new DOMDocument('1.0', 'UTF-8');
@@ -460,31 +460,31 @@  discard block
 block discarded – undo
460 460
         return $this->dom->saveXML();
461 461
     }
462 462
     
463
-   /**
464
-    * Creates a new SimpleXML helper instance: this
465
-    * object is useful to work with loading XML strings
466
-    * and files with easy access to any errors that 
467
-    * may occurr, since the simplexml functions can be
468
-    * somewhat cryptic.
469
-    * 
470
-    * @return XMLHelper_SimpleXML
471
-    */
463
+    /**
464
+     * Creates a new SimpleXML helper instance: this
465
+     * object is useful to work with loading XML strings
466
+     * and files with easy access to any errors that 
467
+     * may occurr, since the simplexml functions can be
468
+     * somewhat cryptic.
469
+     * 
470
+     * @return XMLHelper_SimpleXML
471
+     */
472 472
     public static function createSimplexml() : XMLHelper_SimpleXML
473 473
     {
474 474
         return new XMLHelper_SimpleXML();
475 475
     }
476 476
     
477
-   /**
478
-    * Converts a string to valid XML: can be a text only string
479
-    * or an HTML string. Returns valid XML code.
480
-    * 
481
-    * NOTE: The string may contain custom tags, which are 
482
-    * preserved.
483
-    * 
484
-    * @param string $string
485
-    * @throws XMLHelper_Exception
486
-    * @return string
487
-    */
477
+    /**
478
+     * Converts a string to valid XML: can be a text only string
479
+     * or an HTML string. Returns valid XML code.
480
+     * 
481
+     * NOTE: The string may contain custom tags, which are 
482
+     * preserved.
483
+     * 
484
+     * @param string $string
485
+     * @throws XMLHelper_Exception
486
+     * @return string
487
+     */
488 488
     public static function string2xml(string $string) : string
489 489
     {
490 490
         return XMLHelper_HTMLLoader::loadFragment($string)->fragmentToXML();
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
 
244 244
         if (!empty($text)) {
245 245
             $fragment = $this->dom->createDocumentFragment();
246
-            if(!@$fragment->appendXML($text)) {
246
+            if (!@$fragment->appendXML($text)) {
247 247
                 throw new XMLHelper_Exception(
248 248
                     'Cannot append XML fragment',
249 249
                     sprintf(
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
     * @param array<string,mixed> $attributes
286 286
     * @return DOMNode
287 287
     */
288
-    public function createRoot(string $name, array $attributes=array())
288
+    public function createRoot(string $name, array $attributes = array())
289 289
     {
290 290
         $root = $this->dom->appendChild($this->dom->createElement($name));
291 291
         $this->addAttributes($root, $attributes);
@@ -311,8 +311,8 @@  discard block
 block discarded – undo
311 311
         $string = str_replace('&lt;', 'LT_ESCAPE', $string);
312 312
         $string = str_replace('&gt;', 'GT_ESCAPE', $string);
313 313
 
314
-        $string = str_replace('&nbsp;',' ',  $string);
315
-        $string = str_replace('&','&amp;',  $string);
314
+        $string = str_replace('&nbsp;', ' ', $string);
315
+        $string = str_replace('&', '&amp;', $string);
316 316
 
317 317
         return $string;
318 318
     }
@@ -331,9 +331,9 @@  discard block
 block discarded – undo
331 331
     */
332 332
     public static function downloadXML(string $xml, string $filename = 'download.xml') : void
333 333
     {
334
-        if(!headers_sent() && !self::$simulation) 
334
+        if (!headers_sent() && !self::$simulation) 
335 335
         {
336
-            header('Content-Disposition: attachment; filename="' . $filename . '"');
336
+            header('Content-Disposition: attachment; filename="'.$filename.'"');
337 337
         }
338 338
         
339 339
         echo $xml;
@@ -347,12 +347,12 @@  discard block
 block discarded – undo
347 347
     */
348 348
     public static function displayXML(string $xml) : void
349 349
     {
350
-        if(!headers_sent() && !self::$simulation) 
350
+        if (!headers_sent() && !self::$simulation) 
351 351
         {
352 352
             header('Content-Type:text/xml; charset=utf-8');
353 353
         }
354 354
         
355
-        if(self::$simulation) 
355
+        if (self::$simulation) 
356 356
         {
357 357
             $xml = '<pre>'.htmlspecialchars($xml).'</pre>';
358 358
         }
@@ -370,16 +370,16 @@  discard block
 block discarded – undo
370 370
      * @param array<string,string> $customInfo Associative array with name => value pairs for custom tags to add to the output xml
371 371
      * @see buildErrorXML()
372 372
      */
373
-    public static function displayErrorXML($code, string $message, string $title, array $customInfo=array())
373
+    public static function displayErrorXML($code, string $message, string $title, array $customInfo = array())
374 374
     {
375
-        if(!headers_sent() && !self::$simulation) {
376
-            header('HTTP/1.1 400 Bad Request: ' . $title, true, 400);
375
+        if (!headers_sent() && !self::$simulation) {
376
+            header('HTTP/1.1 400 Bad Request: '.$title, true, 400);
377 377
         }
378 378
 
379 379
         self::displayXML(self::buildErrorXML($code, $message, $title, $customInfo));
380 380
     }
381 381
     
382
-    public static function setSimulation(bool $simulate=true) : void
382
+    public static function setSimulation(bool $simulate = true) : void
383 383
     {
384 384
         self::$simulation = $simulate;
385 385
     }
@@ -428,7 +428,7 @@  discard block
 block discarded – undo
428 428
     * @param array<string,string> $customInfo
429 429
     * @return string
430 430
     */
431
-    public static function buildErrorXML($code, string $message, string $title, array $customInfo=array())
431
+    public static function buildErrorXML($code, string $message, string $title, array $customInfo = array())
432 432
     {
433 433
         $xml = new DOMDocument('1.0', 'UTF-8');
434 434
         $xml->formatOutput = true;
@@ -442,7 +442,7 @@  discard block
 block discarded – undo
442 442
         $helper->addTextTag($root, 'title', $title);
443 443
         $helper->addTextTag($root, 'request_uri', $_SERVER['REQUEST_URI']);
444 444
         
445
-        foreach($customInfo as $name => $value) {
445
+        foreach ($customInfo as $name => $value) {
446 446
             $helper->addTextTag($root, $name, $value);
447 447
         }
448 448
 
Please login to merge, or discard this patch.