Passed
Push — master ( e7a5ba...0bab4c )
by Sebastian
03:04
created
src/RequestHelper.php 1 patch
Indentation   +115 added lines, -115 removed lines patch added patch discarded remove patch
@@ -39,66 +39,66 @@  discard block
 block discarded – undo
39 39
     
40 40
     const ERROR_CANNOT_OPEN_LOGFILE = 17904;
41 41
 
42
-   /**
43
-    * @var string
44
-    */
42
+    /**
43
+     * @var string
44
+     */
45 45
     protected $eol = "\r\n";
46 46
 
47
-   /**
48
-    * @var string
49
-    */
47
+    /**
48
+     * @var string
49
+     */
50 50
     protected $mimeBoundary;
51 51
 
52
-   /**
53
-    * @var string
54
-    */
52
+    /**
53
+     * @var string
54
+     */
55 55
     protected $data = '';
56 56
 
57
-   /**
58
-    * @var string
59
-    */
57
+    /**
58
+     * @var string
59
+     */
60 60
     protected $destination;
61 61
 
62
-   /**
63
-    * @var array
64
-    */
62
+    /**
63
+     * @var array
64
+     */
65 65
     protected $headers = array();
66 66
     
67
-   /**
68
-    * Whether to verify SSL certificates.
69
-    * @var bool
70
-    */
67
+    /**
68
+     * Whether to verify SSL certificates.
69
+     * @var bool
70
+     */
71 71
     protected $verifySSL = true;
72 72
     
73
-   /**
74
-    * @var RequestHelper_Boundaries
75
-    */
73
+    /**
74
+     * @var RequestHelper_Boundaries
75
+     */
76 76
     protected $boundaries;
77 77
     
78
-   /**
79
-    * @var RequestHelper_Response|NULL
80
-    */
78
+    /**
79
+     * @var RequestHelper_Response|NULL
80
+     */
81 81
     protected $response;
82 82
 
83
-   /**
84
-    * @var integer
85
-    */
83
+    /**
84
+     * @var integer
85
+     */
86 86
     protected $timeout = 30;
87 87
     
88
-   /**
89
-    * @var string
90
-    */
88
+    /**
89
+     * @var string
90
+     */
91 91
     protected $logfile = '';
92 92
 
93
-   /**
94
-    * @var resource|NULL
95
-    */
93
+    /**
94
+     * @var resource|NULL
95
+     */
96 96
     protected $logfilePointer = null;
97 97
     
98
-   /**
99
-    * Creates a new request helper to send POST data to the specified destination URL.
100
-    * @param string $destinationURL
101
-    */
98
+    /**
99
+     * Creates a new request helper to send POST data to the specified destination URL.
100
+     * @param string $destinationURL
101
+     */
102 102
     public function __construct(string $destinationURL)
103 103
     {
104 104
         $this->destination = $destinationURL;
@@ -130,13 +130,13 @@  discard block
 block discarded – undo
130 130
         return $this;
131 131
     }
132 132
     
133
-   /**
134
-    * Enables verbose logging of the CURL request, which
135
-    * is then redirected to the target file.
136
-    * 
137
-    * @param string $targetFile
138
-    * @return RequestHelper
139
-    */
133
+    /**
134
+     * Enables verbose logging of the CURL request, which
135
+     * is then redirected to the target file.
136
+     * 
137
+     * @param string $targetFile
138
+     * @return RequestHelper
139
+     */
140 140
     public function enableLogging(string $targetFile) : RequestHelper
141 141
     {
142 142
         $this->logfile = $targetFile;
@@ -144,15 +144,15 @@  discard block
 block discarded – undo
144 144
         return $this;
145 145
     }
146 146
 
147
-   /**
148
-    * Adds a file to be sent with the request.
149
-    *
150
-    * @param string $varName The variable name to send the file in
151
-    * @param string $fileName The name of the file as it should be received at the destination
152
-    * @param string $content The raw content of the file
153
-    * @param string $contentType The content type, use the constants to specify this
154
-    * @param string $encoding The encoding of the file, use the constants to specify this
155
-    */
147
+    /**
148
+     * Adds a file to be sent with the request.
149
+     *
150
+     * @param string $varName The variable name to send the file in
151
+     * @param string $fileName The name of the file as it should be received at the destination
152
+     * @param string $content The raw content of the file
153
+     * @param string $contentType The content type, use the constants to specify this
154
+     * @param string $encoding The encoding of the file, use the constants to specify this
155
+     */
156 156
     public function addFile(string $varName, string $fileName, string $content, string $contentType = '', string $encoding = '') : RequestHelper
157 157
     {
158 158
         $this->boundaries->addFile($varName, $fileName, $content, $contentType, $encoding);
@@ -160,13 +160,13 @@  discard block
 block discarded – undo
160 160
         return $this;
161 161
     }
162 162
     
163
-   /**
164
-    * Adds arbitrary content.
165
-    * 
166
-    * @param string $varName The variable name to send the content in.
167
-    * @param string $content
168
-    * @param string $contentType
169
-    */
163
+    /**
164
+     * Adds arbitrary content.
165
+     * 
166
+     * @param string $varName The variable name to send the content in.
167
+     * @param string $content
168
+     * @param string $contentType
169
+     */
170 170
     public function addContent(string $varName, string $content, string $contentType) : RequestHelper
171 171
     {
172 172
         $this->boundaries->addContent($varName, $content, $contentType);
@@ -188,13 +188,13 @@  discard block
 block discarded – undo
188 188
         return $this;
189 189
     }
190 190
     
191
-   /**
192
-    * Sets an HTTP header to include in the request.
193
-    * 
194
-    * @param string $name
195
-    * @param string $value
196
-    * @return RequestHelper
197
-    */
191
+    /**
192
+     * Sets an HTTP header to include in the request.
193
+     * 
194
+     * @param string $name
195
+     * @param string $value
196
+     * @return RequestHelper
197
+     */
198 198
     public function setHeader(string $name, string $value) : RequestHelper
199 199
     {
200 200
         $this->headers[$name] = $value;
@@ -202,36 +202,36 @@  discard block
 block discarded – undo
202 202
         return $this;
203 203
     }
204 204
     
205
-   /**
206
-    * Disables SSL certificate checking.
207
-    * 
208
-    * @return RequestHelper
209
-    */
205
+    /**
206
+     * Disables SSL certificate checking.
207
+     * 
208
+     * @return RequestHelper
209
+     */
210 210
     public function disableSSLChecks() : RequestHelper
211 211
     {
212 212
         $this->verifySSL = false;
213 213
         return $this;
214 214
     }
215 215
    
216
-   /**
217
-    * @var integer
218
-    */
216
+    /**
217
+     * @var integer
218
+     */
219 219
     protected $contentLength = 0;
220 220
 
221
-   /**
222
-    * Sends the POST request to the destination, and returns
223
-    * the response text.
224
-    *
225
-    * The response object is stored internally, so after calling
226
-    * this method it may be retrieved at any moment using the
227
-    * {@link getResponse()} method.
228
-    *
229
-    * @return string
230
-    * @see RequestHelper::getResponse()
231
-    * @throws RequestHelper_Exception
232
-    * 
233
-    * @see RequestHelper::ERROR_REQUEST_FAILED
234
-    */
221
+    /**
222
+     * Sends the POST request to the destination, and returns
223
+     * the response text.
224
+     *
225
+     * The response object is stored internally, so after calling
226
+     * this method it may be retrieved at any moment using the
227
+     * {@link getResponse()} method.
228
+     *
229
+     * @return string
230
+     * @see RequestHelper::getResponse()
231
+     * @throws RequestHelper_Exception
232
+     * 
233
+     * @see RequestHelper::ERROR_REQUEST_FAILED
234
+     */
235 235
     public function send() : string
236 236
     {
237 237
         $info = parseURL($this->destination);
@@ -274,14 +274,14 @@  discard block
 block discarded – undo
274 274
         return $this->data;
275 275
     }
276 276
     
277
-   /**
278
-    * Creates a new CURL resource configured according to the
279
-    * request's settings.
280
-    * 
281
-    * @param URLInfo $url
282
-    * @throws RequestHelper_Exception
283
-    * @return resource
284
-    */
277
+    /**
278
+     * Creates a new CURL resource configured according to the
279
+     * request's settings.
280
+     * 
281
+     * @param URLInfo $url
282
+     * @throws RequestHelper_Exception
283
+     * @return resource
284
+     */
285 285
     protected function createCURL(URLInfo $url)
286 286
     {
287 287
         $ch = curl_init();
@@ -329,10 +329,10 @@  discard block
 block discarded – undo
329 329
         return $ch;
330 330
     }
331 331
     
332
-   /**
333
-    * @param resource $ch
334
-    * @return bool Whether logging is enabled.
335
-    */
332
+    /**
333
+     * @param resource $ch
334
+     * @return bool Whether logging is enabled.
335
+     */
336 336
     protected function configureLogging($ch) : bool
337 337
     {
338 338
         if(empty($this->logfile))
@@ -359,13 +359,13 @@  discard block
 block discarded – undo
359 359
         return true;
360 360
     }
361 361
 
362
-   /**
363
-    * Compiles the associative headers array into
364
-    * the format understood by CURL, namely an indexed
365
-    * array with one header string per entry.
366
-    * 
367
-    * @return array
368
-    */
362
+    /**
363
+     * Compiles the associative headers array into
364
+     * the format understood by CURL, namely an indexed
365
+     * array with one header string per entry.
366
+     * 
367
+     * @return array
368
+     */
369 369
     protected function renderHeaders() : array
370 370
     {
371 371
         $result = array();
@@ -379,12 +379,12 @@  discard block
 block discarded – undo
379 379
         return $result;
380 380
     }
381 381
     
382
-   /**
383
-    * Retrieves the raw response header, in the form of an indexed
384
-    * array containing all response header lines.
385
-    * 
386
-    * @return array
387
-    */
382
+    /**
383
+     * Retrieves the raw response header, in the form of an indexed
384
+     * array containing all response header lines.
385
+     * 
386
+     * @return array
387
+     */
388 388
     public function getResponseHeader() : array
389 389
     {
390 390
         $response = $this->getResponse();
Please login to merge, or discard this patch.
src/OperationResult.php 1 patch
Indentation   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -27,73 +27,73 @@  discard block
 block discarded – undo
27 27
  */
28 28
 class OperationResult
29 29
 {
30
-   /**
31
-    * @var string
32
-    */
30
+    /**
31
+     * @var string
32
+     */
33 33
     protected $message = '';
34 34
     
35
-   /**
36
-    * @var bool
37
-    */
35
+    /**
36
+     * @var bool
37
+     */
38 38
     protected $valid = true;
39 39
   
40
-   /**
41
-    * @var object
42
-    */
40
+    /**
41
+     * @var object
42
+     */
43 43
     protected $subject;
44 44
     
45
-   /**
46
-    * @var integer
47
-    */
45
+    /**
46
+     * @var integer
47
+     */
48 48
     protected $code = 0;
49 49
     
50
-   /**
51
-    * The subject being validated.
52
-    * 
53
-    * @param object $subject
54
-    */
50
+    /**
51
+     * The subject being validated.
52
+     * 
53
+     * @param object $subject
54
+     */
55 55
     public function __construct(object $subject)
56 56
     {
57 57
         $this->subject = $subject;
58 58
     }
59 59
     
60
-   /**
61
-    * Whether the validation was successful.
62
-    * 
63
-    * @return bool
64
-    */
60
+    /**
61
+     * Whether the validation was successful.
62
+     * 
63
+     * @return bool
64
+     */
65 65
     public function isValid() : bool
66 66
     {
67 67
         return $this->valid;
68 68
     }
69 69
     
70
-   /**
71
-    * Retrieves the subject that was validated.
72
-    * 
73
-    * @return object
74
-    */
70
+    /**
71
+     * Retrieves the subject that was validated.
72
+     * 
73
+     * @return object
74
+     */
75 75
     public function getSubject() : object
76 76
     {
77 77
         return $this->subject;
78 78
     }
79 79
     
80
-   /**
81
-    * Makes the result a succes, with the specified message.
82
-    * 
83
-    * @param string $message Should not contain a date, just the system specific info.
84
-    * @return OperationResult
85
-    */
80
+    /**
81
+     * Makes the result a succes, with the specified message.
82
+     * 
83
+     * @param string $message Should not contain a date, just the system specific info.
84
+     * @return OperationResult
85
+     */
86 86
     public function makeSuccess(string $message, int $code=0) : OperationResult
87 87
     {
88 88
         return $this->setMessage($message, $code, true);
89 89
     }
90 90
     
91
-   /**
92
-    * Sets the result as an error.
93
-    * 
94
-    * @param string $message Should be as detailed as possible.
95
-    * @return OperationResult
96
-    */
91
+    /**
92
+     * Sets the result as an error.
93
+     * 
94
+     * @param string $message Should be as detailed as possible.
95
+     * @return OperationResult
96
+     */
97 97
     public function makeError(string $message, int $code=0) : OperationResult
98 98
     {
99 99
         return $this->setMessage($message, $code, false);
@@ -108,21 +108,21 @@  discard block
 block discarded – undo
108 108
         return $this;
109 109
     }
110 110
     
111
-   /**
112
-    * Retrieves the error message, if an error occurred.
113
-    * 
114
-    * @return string The error message, or an empty string if no error occurred.
115
-    */
111
+    /**
112
+     * Retrieves the error message, if an error occurred.
113
+     * 
114
+     * @return string The error message, or an empty string if no error occurred.
115
+     */
116 116
     public function getErrorMessage() : string
117 117
     {
118 118
         return $this->getMessage(false);
119 119
     }
120 120
     
121
-   /**
122
-    * Retrieves the success message, if one has been provided.
123
-    * 
124
-    * @return string
125
-    */
121
+    /**
122
+     * Retrieves the success message, if one has been provided.
123
+     * 
124
+     * @return string
125
+     */
126 126
     public function getSuccessMessage() : string
127 127
     {
128 128
         return $this->getMessage(true);
Please login to merge, or discard this patch.
src/Traits/Classable.php 1 patch
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -87,37 +87,37 @@
 block discarded – undo
87 87
  */
88 88
 interface Interface_Classable
89 89
 {
90
-   /**
91
-    * @param string $name
92
-    * @return $this
93
-    */
90
+    /**
91
+     * @param string $name
92
+     * @return $this
93
+     */
94 94
     public function addClass(string $name);
95 95
 
96
-   /**
97
-    * @param array $names
98
-    * @return $this
99
-    */
96
+    /**
97
+     * @param array $names
98
+     * @return $this
99
+     */
100 100
     public function addClasses(array $names);
101 101
     
102
-   /**
103
-    * @param string $name
104
-    * @return bool
105
-    */
102
+    /**
103
+     * @param string $name
104
+     * @return bool
105
+     */
106 106
     public function hasClass(string $name) : bool;
107 107
     
108
-   /**
109
-    * @param string $name
110
-    * @return $this
111
-    */
108
+    /**
109
+     * @param string $name
110
+     * @return $this
111
+     */
112 112
     public function removeClass(string $name);
113 113
     
114
-   /**
115
-    * @return array
116
-    */
114
+    /**
115
+     * @return array
116
+     */
117 117
     public function getClasses() : array;
118 118
     
119
-   /**
120
-    * @return string
121
-    */
119
+    /**
120
+     * @return string
121
+     */
122 122
     public function classesToString() : string;
123 123
 }
Please login to merge, or discard this patch.
src/Traits/Optionable.php 1 patch
Indentation   +100 added lines, -100 removed lines patch added patch discarded remove patch
@@ -26,18 +26,18 @@  discard block
 block discarded – undo
26 26
  */
27 27
 trait Traits_Optionable
28 28
 {
29
-   /**
30
-    * @var array
31
-    */
29
+    /**
30
+     * @var array
31
+     */
32 32
     protected $options;
33 33
     
34
-   /**
35
-    * Sets an option to the specified value. This can be any
36
-    * kind of variable type, including objects, as needed.
37
-    * 
38
-    * @param string $name
39
-    * @param mixed $value
40
-    */
34
+    /**
35
+     * Sets an option to the specified value. This can be any
36
+     * kind of variable type, including objects, as needed.
37
+     * 
38
+     * @param string $name
39
+     * @param mixed $value
40
+     */
41 41
     public function setOption(string $name, $value)
42 42
     {
43 43
         if(!isset($this->options)) {
@@ -48,12 +48,12 @@  discard block
 block discarded – undo
48 48
         return $this;
49 49
     }
50 50
     
51
-   /**
52
-    * Sets a collection of options at once, from an
53
-    * associative array.
54
-    * 
55
-    * @param array $options
56
-    */
51
+    /**
52
+     * Sets a collection of options at once, from an
53
+     * associative array.
54
+     * 
55
+     * @param array $options
56
+     */
57 57
     public function setOptions(array $options)
58 58
     {
59 59
         foreach($options as $name => $value) {
@@ -63,16 +63,16 @@  discard block
 block discarded – undo
63 63
         return $this;
64 64
     }
65 65
     
66
-   /**
67
-    * Retrieves an option's value.
68
-    * 
69
-    * NOTE: Use the specialized type getters to ensure an option
70
-    * contains the expected type (for ex. getArrayOption()). 
71
-    * 
72
-    * @param string $name
73
-    * @param mixed $default The default value to return if the option does not exist.
74
-    * @return mixed
75
-    */
66
+    /**
67
+     * Retrieves an option's value.
68
+     * 
69
+     * NOTE: Use the specialized type getters to ensure an option
70
+     * contains the expected type (for ex. getArrayOption()). 
71
+     * 
72
+     * @param string $name
73
+     * @param mixed $default The default value to return if the option does not exist.
74
+     * @return mixed
75
+     */
76 76
     public function getOption(string $name, $default=null)
77 77
     {
78 78
         if(!isset($this->options)) {
@@ -86,16 +86,16 @@  discard block
 block discarded – undo
86 86
         return $default;
87 87
     }
88 88
     
89
-   /**
90
-    * Enforces that the option value is a string. Numbers are converted
91
-    * to string, strings are passed through, and all other types will 
92
-    * return the default value. The default value is also returned if
93
-    * the string is empty.
94
-    * 
95
-    * @param string $name
96
-    * @param string $default Used if the option does not exist, is invalid, or empty.
97
-    * @return string
98
-    */
89
+    /**
90
+     * Enforces that the option value is a string. Numbers are converted
91
+     * to string, strings are passed through, and all other types will 
92
+     * return the default value. The default value is also returned if
93
+     * the string is empty.
94
+     * 
95
+     * @param string $name
96
+     * @param string $default Used if the option does not exist, is invalid, or empty.
97
+     * @return string
98
+     */
99 99
     public function getStringOption(string $name, string $default='') : string
100 100
     {
101 101
         $value = $this->getOption($name, false);
@@ -107,15 +107,15 @@  discard block
 block discarded – undo
107 107
         return $default;
108 108
     }
109 109
     
110
-   /**
111
-    * Treats the option value as a boolean value: will return
112
-    * true if the value actually is a boolean true.
113
-    * 
114
-    * NOTE: boolean string representations are not accepted.
115
-    * 
116
-    * @param string $name
117
-    * @return bool
118
-    */
110
+    /**
111
+     * Treats the option value as a boolean value: will return
112
+     * true if the value actually is a boolean true.
113
+     * 
114
+     * NOTE: boolean string representations are not accepted.
115
+     * 
116
+     * @param string $name
117
+     * @return bool
118
+     */
119 119
     public function getBoolOption(string $name, bool $default=false) : bool
120 120
     {
121 121
         if($this->getOption($name) === true) {
@@ -125,15 +125,15 @@  discard block
 block discarded – undo
125 125
         return $default;
126 126
     }
127 127
     
128
-   /**
129
-    * Treats the option value as an integer value: will return
130
-    * valid integer values (also from integer strings), or the
131
-    * default value otherwise.
132
-    * 
133
-    * @param string $name
134
-    * @param int $default
135
-    * @return int
136
-    */
128
+    /**
129
+     * Treats the option value as an integer value: will return
130
+     * valid integer values (also from integer strings), or the
131
+     * default value otherwise.
132
+     * 
133
+     * @param string $name
134
+     * @param int $default
135
+     * @return int
136
+     */
137 137
     public function getIntOption(string $name, int $default=0) : int
138 138
     {
139 139
         $value = $this->getOption($name);
@@ -144,14 +144,14 @@  discard block
 block discarded – undo
144 144
         return $default;
145 145
     }
146 146
     
147
-   /**
148
-    * Treats an option as an array, and returns its value
149
-    * only if it contains an array - otherwise, an empty
150
-    * array is returned.
151
-    * 
152
-    * @param string $name
153
-    * @return array
154
-    */
147
+    /**
148
+     * Treats an option as an array, and returns its value
149
+     * only if it contains an array - otherwise, an empty
150
+     * array is returned.
151
+     * 
152
+     * @param string $name
153
+     * @return array
154
+     */
155 155
     public function getArrayOption(string $name) : array
156 156
     {
157 157
         $val = $this->getOption($name);
@@ -162,13 +162,13 @@  discard block
 block discarded – undo
162 162
         return array();
163 163
     }
164 164
     
165
-   /**
166
-    * Checks whether the specified option exists - even
167
-    * if it has a NULL value.
168
-    * 
169
-    * @param string $name
170
-    * @return bool
171
-    */
165
+    /**
166
+     * Checks whether the specified option exists - even
167
+     * if it has a NULL value.
168
+     * 
169
+     * @param string $name
170
+     * @return bool
171
+     */
172 172
     public function hasOption(string $name) : bool
173 173
     {
174 174
         if(!isset($this->options)) {
@@ -178,10 +178,10 @@  discard block
 block discarded – undo
178 178
         return array_key_exists($name, $this->options);
179 179
     }
180 180
     
181
-   /**
182
-    * Returns all options in one associative array.
183
-    * @return array
184
-    */
181
+    /**
182
+     * Returns all options in one associative array.
183
+     * @return array
184
+     */
185 185
     public function getOptions() : array
186 186
     {
187 187
         if(!isset($this->options)) {
@@ -191,24 +191,24 @@  discard block
 block discarded – undo
191 191
         return $this->options;
192 192
     }
193 193
     
194
-   /**
195
-    * Checks whether the option's value is the one specified.
196
-    * 
197
-    * @param string $name
198
-    * @param mixed $value
199
-    * @return bool
200
-    */
194
+    /**
195
+     * Checks whether the option's value is the one specified.
196
+     * 
197
+     * @param string $name
198
+     * @param mixed $value
199
+     * @return bool
200
+     */
201 201
     public function isOption(string $name, $value) : bool
202 202
     {
203 203
         return $this->getOption($name) === $value;
204 204
     }
205 205
     
206
-   /**
207
-    * Retrieves the default available options as an 
208
-    * associative array with option name => value pairs.
209
-    * 
210
-    * @return array
211
-    */
206
+    /**
207
+     * Retrieves the default available options as an 
208
+     * associative array with option name => value pairs.
209
+     * 
210
+     * @return array
211
+     */
212 212
     abstract public function getDefaultOptions() : array;
213 213
 }
214 214
 
@@ -226,24 +226,24 @@  discard block
 block discarded – undo
226 226
  */
227 227
 interface Interface_Optionable
228 228
 {
229
-   /**
230
-    * @param string $name
231
-    * @param mixed $value
232
-    * @return $this
233
-    */
229
+    /**
230
+     * @param string $name
231
+     * @param mixed $value
232
+     * @return $this
233
+     */
234 234
     function setOption(string $name, $value);
235 235
     
236
-   /**
237
-    * @param string $name
238
-    * @param mixed $default
239
-    * @return $this
240
-    */
236
+    /**
237
+     * @param string $name
238
+     * @param mixed $default
239
+     * @return $this
240
+     */
241 241
     function getOption(string $name, $default=null);
242 242
     
243
-   /**
244
-    * @param array $options
245
-    * @return $this    
246
-    */
243
+    /**
244
+     * @param array $options
245
+     * @return $this    
246
+     */
247 247
     function setOptions(array $options);
248 248
     function getOptions() : array;
249 249
     function isOption(string $name, $value) : bool;
Please login to merge, or discard this patch.