Passed
Push — master ( 12a81e...e685ae )
by Sebastian
02:29
created
src/RequestHelper/Boundaries.php 2 patches
Indentation   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -22,19 +22,19 @@  discard block
 block discarded – undo
22 22
 {
23 23
     const ERROR_NO_BOUNDARIES_SPECIFIED = 44401;
24 24
     
25
-   /**
26
-    * @var RequestHelper
27
-    */
25
+    /**
26
+     * @var RequestHelper
27
+     */
28 28
     protected $helper;
29 29
 
30
-   /**
31
-    * @var RequestHelper_Boundaries_Boundary[]
32
-    */
30
+    /**
31
+     * @var RequestHelper_Boundaries_Boundary[]
32
+     */
33 33
     protected $boundaries = array();
34 34
     
35
-   /**
36
-    * @var integer
37
-    */
35
+    /**
36
+     * @var integer
37
+     */
38 38
     protected $contentLength = 0;
39 39
     
40 40
     public function __construct(RequestHelper $helper)
@@ -42,45 +42,45 @@  discard block
 block discarded – undo
42 42
         $this->helper = $helper;
43 43
     }
44 44
     
45
-   /**
46
-    * Retrieves the string that is used to separate mime boundaries in the body.
47
-    * 
48
-    * @return string
49
-    */
45
+    /**
46
+     * Retrieves the string that is used to separate mime boundaries in the body.
47
+     * 
48
+     * @return string
49
+     */
50 50
     public function getMimeBoundary() : string
51 51
     {
52 52
         return $this->helper->getMimeBoundary();
53 53
     }
54 54
     
55
-   /**
56
-    * Retrieves the end of line character(s) used in the body.
57
-    * 
58
-    * @return string
59
-    */
55
+    /**
56
+     * Retrieves the end of line character(s) used in the body.
57
+     * 
58
+     * @return string
59
+     */
60 60
     public function getEOL() : string
61 61
     {
62 62
         return $this->helper->getEOL();
63 63
     }
64 64
     
65
-   /**
66
-    * Retrieves the total content length of all boundary contents.
67
-    * 
68
-    * @return int
69
-    */
65
+    /**
66
+     * Retrieves the total content length of all boundary contents.
67
+     * 
68
+     * @return int
69
+     */
70 70
     public function getContentLength() : int
71 71
     {
72 72
         return $this->contentLength;
73 73
     }
74 74
     
75
-   /**
76
-    * Adds a file to be sent with the request.
77
-    *
78
-    * @param string $varName The variable name to send the file in
79
-    * @param string $fileName The name of the file as it should be received at the destination
80
-    * @param string $content The raw content of the file
81
-    * @param string $contentType The content type, use the constants to specify this
82
-    * @param string $encoding The encoding of the file, use the constants to specify this
83
-    */
75
+    /**
76
+     * Adds a file to be sent with the request.
77
+     *
78
+     * @param string $varName The variable name to send the file in
79
+     * @param string $fileName The name of the file as it should be received at the destination
80
+     * @param string $content The raw content of the file
81
+     * @param string $contentType The content type, use the constants to specify this
82
+     * @param string $encoding The encoding of the file, use the constants to specify this
83
+     */
84 84
     public function addFile(string $varName, string $fileName, string $content, string $contentType = RequestHelper::FILETYPE_TEXT, string $encoding = RequestHelper::ENCODING_UTF8) : RequestHelper_Boundaries
85 85
     {
86 86
         $boundary = $this->createBoundary(chunk_split(base64_encode($content)))
@@ -92,13 +92,13 @@  discard block
 block discarded – undo
92 92
         return $this->addBoundary($boundary);
93 93
     }
94 94
     
95
-   /**
96
-    * Adds arbitrary content.
97
-    *
98
-    * @param string $varName
99
-    * @param string $content
100
-    * @param string $contentType
101
-    */
95
+    /**
96
+     * Adds arbitrary content.
97
+     *
98
+     * @param string $varName
99
+     * @param string $content
100
+     * @param string $contentType
101
+     */
102 102
     public function addContent(string $varName, string $content, string $contentType) : RequestHelper_Boundaries
103 103
     {
104 104
         $boundary = $this->createBoundary($content)
@@ -109,13 +109,13 @@  discard block
 block discarded – undo
109 109
         return $this->addBoundary($boundary);
110 110
     }
111 111
     
112
-   /**
113
-    * Adds a variable to be sent with the request. If it
114
-    * already exists, its value is overwritten.
115
-    *
116
-    * @param string $name
117
-    * @param string $value
118
-    */
112
+    /**
113
+     * Adds a variable to be sent with the request. If it
114
+     * already exists, its value is overwritten.
115
+     *
116
+     * @param string $name
117
+     * @param string $value
118
+     */
119 119
     public function addVariable(string $name, string $value) : RequestHelper_Boundaries
120 120
     {
121 121
         $boundary = $this->createBoundary($value)
@@ -132,11 +132,11 @@  discard block
 block discarded – undo
132 132
         return $this;
133 133
     }
134 134
     
135
-   /**
136
-    * Renders the response body with all mime boundaries.
137
-    * 
138
-    * @return string
139
-    */
135
+    /**
136
+     * Renders the response body with all mime boundaries.
137
+     * 
138
+     * @return string
139
+     */
140 140
     public function render() : string
141 141
     {
142 142
         if(empty($this->boundaries)) 
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
     */
140 140
     public function render() : string
141 141
     {
142
-        if(empty($this->boundaries)) 
142
+        if (empty($this->boundaries)) 
143 143
         {
144 144
             throw new RequestHelper_Exception(
145 145
                 'No mime boundaries added',
@@ -150,13 +150,13 @@  discard block
 block discarded – undo
150 150
         
151 151
         $result = '';
152 152
         
153
-        foreach($this->boundaries as $boundary)
153
+        foreach ($this->boundaries as $boundary)
154 154
         {
155 155
             $result .= $boundary->render();
156 156
         }
157 157
         
158
-        $result .= "--" . $this->getMimeBoundary() . "--" . 
159
-        $this->getEOL() . $this->getEOL(); // always finish with two eol's!!
158
+        $result .= "--".$this->getMimeBoundary()."--". 
159
+        $this->getEOL().$this->getEOL(); // always finish with two eol's!!
160 160
         
161 161
         return $result;
162 162
     }
Please login to merge, or discard this patch.
src/RequestHelper/Boundaries/Boundary.php 1 patch
Indentation   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -19,29 +19,29 @@  discard block
 block discarded – undo
19 19
  */
20 20
 class RequestHelper_Boundaries_Boundary
21 21
 {
22
-   /**
23
-    * @var string
24
-    */
22
+    /**
23
+     * @var string
24
+     */
25 25
     protected $content;
26 26
     
27
-   /**
28
-    * @var array
29
-    */
27
+    /**
28
+     * @var array
29
+     */
30 30
     protected $dispositionParams = array();
31 31
 
32
-   /**
33
-    * @var string
34
-    */
32
+    /**
33
+     * @var string
34
+     */
35 35
     protected $contentType = '';
36 36
 
37
-   /**
38
-    * @var string
39
-    */
37
+    /**
38
+     * @var string
39
+     */
40 40
     protected $contentEncoding = '';
41 41
     
42
-   /**
43
-    * @var RequestHelper_Boundaries
44
-    */
42
+    /**
43
+     * @var RequestHelper_Boundaries
44
+     */
45 45
     protected $boundaries;
46 46
     
47 47
     public function __construct(RequestHelper_Boundaries $boundaries, string $content)
@@ -55,46 +55,46 @@  discard block
 block discarded – undo
55 55
         return strlen($this->content);
56 56
     }
57 57
     
58
-   /**
59
-    * Sets the name of the request parameter.
60
-    * 
61
-    * @param string $name
62
-    * @return RequestHelper_Boundaries_Boundary
63
-    */
58
+    /**
59
+     * Sets the name of the request parameter.
60
+     * 
61
+     * @param string $name
62
+     * @return RequestHelper_Boundaries_Boundary
63
+     */
64 64
     public function setName(string $name) : RequestHelper_Boundaries_Boundary
65 65
     {
66 66
         return $this->setDispositionParam('name', $name);
67 67
     }
68 68
     
69
-   /**
70
-    * Sets the filename to use for the content, if applicable.
71
-    *  
72
-    * @param string $fileName
73
-    * @return RequestHelper_Boundaries_Boundary
74
-    */
69
+    /**
70
+     * Sets the filename to use for the content, if applicable.
71
+     *  
72
+     * @param string $fileName
73
+     * @return RequestHelper_Boundaries_Boundary
74
+     */
75 75
     public function setFileName(string $fileName) : RequestHelper_Boundaries_Boundary
76 76
     {
77 77
         return $this->setDispositionParam('filename', $fileName);
78 78
     }
79 79
     
80
-   /**
81
-    * Sets the content type to use for the content.
82
-    * 
83
-    * @param string $contentType
84
-    * @return RequestHelper_Boundaries_Boundary
85
-    */
80
+    /**
81
+     * Sets the content type to use for the content.
82
+     * 
83
+     * @param string $contentType
84
+     * @return RequestHelper_Boundaries_Boundary
85
+     */
86 86
     public function setContentType(string $contentType) : RequestHelper_Boundaries_Boundary
87 87
     {
88 88
         $this->contentType = $contentType;
89 89
         return $this;
90 90
     }
91 91
     
92
-   /**
93
-    * Sets the encoding to specify for the content.
94
-    * 
95
-    * @param string $encoding An encoding string, e.g. "UTF-8", "ASCII"
96
-    * @return RequestHelper_Boundaries_Boundary
97
-    */
92
+    /**
93
+     * Sets the encoding to specify for the content.
94
+     * 
95
+     * @param string $encoding An encoding string, e.g. "UTF-8", "ASCII"
96
+     * @return RequestHelper_Boundaries_Boundary
97
+     */
98 98
     public function setContentEncoding(string $encoding) : RequestHelper_Boundaries_Boundary
99 99
     {
100 100
         $this->contentEncoding = $encoding;
@@ -107,11 +107,11 @@  discard block
 block discarded – undo
107 107
         return $this;
108 108
     }
109 109
     
110
-   /**
111
-    * Renders the mime boundary text.
112
-    * 
113
-    * @return string
114
-    */
110
+    /**
111
+     * Renders the mime boundary text.
112
+     * 
113
+     * @return string
114
+     */
115 115
     public function render()
116 116
     {
117 117
         $eol = $this->boundaries->getEOL();
Please login to merge, or discard this patch.
src/RequestHelper/Response.php 1 patch
Indentation   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -19,51 +19,51 @@  discard block
 block discarded – undo
19 19
  */
20 20
 class RequestHelper_Response
21 21
 {
22
-   /**
23
-    * @var RequestHelper
24
-    */
22
+    /**
23
+     * @var RequestHelper
24
+     */
25 25
     protected $request;
26 26
     
27
-   /**
28
-    * @var string
29
-    */
27
+    /**
28
+     * @var string
29
+     */
30 30
     protected $body = '';
31 31
     
32
-   /**
33
-    * @var array
34
-    */
32
+    /**
33
+     * @var array
34
+     */
35 35
     protected $info;
36 36
     
37
-   /**
38
-    * @var bool
39
-    */
37
+    /**
38
+     * @var bool
39
+     */
40 40
     protected $isError = false;
41 41
     
42
-   /**
43
-    * @var string
44
-    */
42
+    /**
43
+     * @var string
44
+     */
45 45
     protected $errorMessage = '';
46 46
     
47
-   /**
48
-    * @var integer
49
-    */
47
+    /**
48
+     * @var integer
49
+     */
50 50
     protected $errorCode = 0;
51 51
     
52
-   /**
53
-    * @param RequestHelper $helper
54
-    * @param array $info The CURL info array from curl_getinfo().
55
-    */
52
+    /**
53
+     * @param RequestHelper $helper
54
+     * @param array $info The CURL info array from curl_getinfo().
55
+     */
56 56
     public function __construct(RequestHelper $helper, array $info)
57 57
     {
58 58
         $this->request = $helper;
59 59
         $this->info = $info;
60 60
     }
61 61
     
62
-   /**
63
-    * Retrieves the request instance that initiated the request.
64
-    *  
65
-    * @return RequestHelper
66
-    */
62
+    /**
63
+     * Retrieves the request instance that initiated the request.
64
+     *  
65
+     * @return RequestHelper
66
+     */
67 67
     public function getRequest() : RequestHelper
68 68
     {
69 69
         return $this->request;
@@ -84,70 +84,70 @@  discard block
 block discarded – undo
84 84
         return $this;
85 85
     }
86 86
     
87
-   /**
88
-    * Whether an error occurred in the request.
89
-    * @return bool
90
-    */
87
+    /**
88
+     * Whether an error occurred in the request.
89
+     * @return bool
90
+     */
91 91
     public function isError() : bool
92 92
     {
93 93
         return $this->isError;
94 94
     }
95 95
     
96
-   /**
97
-    * Retrieves the native error message, if an error occurred.
98
-    * @return string
99
-    */
96
+    /**
97
+     * Retrieves the native error message, if an error occurred.
98
+     * @return string
99
+     */
100 100
     public function getErrorMessage() : string
101 101
     {
102 102
         return $this->errorMessage;
103 103
     }
104 104
     
105
-   /**
106
-    * Retrieves the native error code, if an error occurred.
107
-    * @return int
108
-    */
105
+    /**
106
+     * Retrieves the native error code, if an error occurred.
107
+     * @return int
108
+     */
109 109
     public function getErrorCode() : int
110 110
     {
111 111
         return $this->errorCode;
112 112
     }
113 113
     
114 114
     
115
-   /**
116
-    * Retrieves the full body of the request.
117
-    * 
118
-    * @return string
119
-    */
115
+    /**
116
+     * Retrieves the full body of the request.
117
+     * 
118
+     * @return string
119
+     */
120 120
     public function getRequestBody() : string
121 121
     {
122 122
         return $this->request->getBody();
123 123
     }
124 124
     
125
-   /**
126
-    * Retrieves the body of the response, if any.
127
-    * 
128
-    * @return string
129
-    */
125
+    /**
126
+     * Retrieves the body of the response, if any.
127
+     * 
128
+     * @return string
129
+     */
130 130
     public function getResponseBody() : string
131 131
     {
132 132
         return $this->body;
133 133
     }
134 134
     
135
-   /**
136
-    * The response HTTP code.
137
-    * 
138
-    * @return int The code, or 0 if none was sent (on error).
139
-    */
135
+    /**
136
+     * The response HTTP code.
137
+     * 
138
+     * @return int The code, or 0 if none was sent (on error).
139
+     */
140 140
     public function getCode() : int
141 141
     {
142 142
         return intval($this->getInfoKey('http_code'));
143 143
     }
144 144
     
145
-   /**
146
-    * Retrieves the actual headers that were sent in the request:
147
-    * one header by entry in the indexed array.
148
-    * 
149
-    * @return array
150
-    */
145
+    /**
146
+     * Retrieves the actual headers that were sent in the request:
147
+     * one header by entry in the indexed array.
148
+     * 
149
+     * @return array
150
+     */
151 151
     public function getHeaders() : array
152 152
     {
153 153
         return ConvertHelper::explodeTrim("\n", $this->getInfoKey('request_header'));
Please login to merge, or discard this patch.
src/URLInfo/Normalizer.php 2 patches
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -32,23 +32,23 @@
 block discarded – undo
32 32
         $this->info = $info;
33 33
     }
34 34
     
35
-   /**
36
-    * Enables the authentication information in the URL,
37
-    * if a username and password are present.
38
-    * 
39
-    * @param bool $enable Whether to turn it on or off.
40
-    * @return URLInfo_Normalizer
41
-    */
35
+    /**
36
+     * Enables the authentication information in the URL,
37
+     * if a username and password are present.
38
+     * 
39
+     * @param bool $enable Whether to turn it on or off.
40
+     * @return URLInfo_Normalizer
41
+     */
42 42
     public function enableAuth(bool $enable=true) : URLInfo_Normalizer
43 43
     {
44 44
         $this->auth = $enable;
45 45
         return $this;
46 46
     }
47 47
     
48
-   /**
49
-    * Retrieves the normalized URL.
50
-    * @return string
51
-    */
48
+    /**
49
+     * Retrieves the normalized URL.
50
+     * @return string
51
+     */
52 52
     public function normalize() : string
53 53
     {
54 54
         $method = 'normalize_'.$this->info->getType();
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
     * @param bool $enable Whether to turn it on or off.
40 40
     * @return URLInfo_Normalizer
41 41
     */
42
-    public function enableAuth(bool $enable=true) : URLInfo_Normalizer
42
+    public function enableAuth(bool $enable = true) : URLInfo_Normalizer
43 43
     {
44 44
         $this->auth = $enable;
45 45
         return $this;
@@ -86,48 +86,48 @@  discard block
 block discarded – undo
86 86
     
87 87
     protected function renderAuth(string $normalized) : string
88 88
     {
89
-        if(!$this->info->hasUsername() || !$this->auth) {
89
+        if (!$this->info->hasUsername() || !$this->auth) {
90 90
             return $normalized;
91 91
         }
92 92
          
93
-        return $normalized . urlencode($this->info->getUsername()).':'.urlencode($this->info->getPassword()).'@';
93
+        return $normalized.urlencode($this->info->getUsername()).':'.urlencode($this->info->getPassword()).'@';
94 94
     }
95 95
     
96 96
     protected function renderPort(string $normalized) : string
97 97
     {
98
-        if(!$this->info->hasPort()) {
98
+        if (!$this->info->hasPort()) {
99 99
             return $normalized;
100 100
         }
101 101
         
102
-        return $normalized . ':'.$this->info->getPort();
102
+        return $normalized.':'.$this->info->getPort();
103 103
     }
104 104
     
105 105
     protected function renderPath(string $normalized) : string
106 106
     {
107
-        if(!$this->info->hasPath()) {
107
+        if (!$this->info->hasPath()) {
108 108
             return $normalized; 
109 109
         }
110 110
         
111
-        return $normalized . $this->info->getPath();
111
+        return $normalized.$this->info->getPath();
112 112
     }
113 113
     
114 114
     protected function renderParams(string $normalized) : string
115 115
     {
116 116
         $params = $this->info->getParams();
117 117
         
118
-        if(empty($params)) {
118
+        if (empty($params)) {
119 119
             return $normalized;
120 120
         }
121 121
         
122
-        return $normalized . '?'.http_build_query($params);
122
+        return $normalized.'?'.http_build_query($params);
123 123
     }
124 124
     
125 125
     protected function renderFragment(string $normalized) : string
126 126
     {
127
-        if(!$this->info->hasFragment()) {
127
+        if (!$this->info->hasFragment()) {
128 128
             return $normalized;
129 129
         }
130 130
         
131
-        return $normalized . '#'.$this->info->getFragment();
131
+        return $normalized.'#'.$this->info->getFragment();
132 132
     }
133 133
 }
Please login to merge, or discard this patch.
src/ConvertHelper/IntervalConverter.php 1 patch
Indentation   +38 added lines, -39 removed lines patch added patch discarded remove patch
@@ -17,21 +17,20 @@  discard block
 block discarded – undo
17 17
  * @package Application Utils
18 18
  * @subpackage ConvertHelper
19 19
  * @author Sebastian Mordziol <[email protected]>
20
-
21 20
  * @see ConvertHelper::interval2string()
22 21
  */
23 22
 class ConvertHelper_IntervalConverter
24 23
 {
25 24
     const ERROR_MISSING_TRANSLATION = 43501;
26 25
     
27
-   /**
28
-    * @var array|NULL
29
-    */
26
+    /**
27
+     * @var array|NULL
28
+     */
30 29
     protected static $texts = null;
31 30
     
32
-   /**
33
-    * @var array
34
-    */
31
+    /**
32
+     * @var array
33
+     */
35 34
     protected $tokens = array('y', 'm', 'd', 'h', 'i', 's');
36 35
     
37 36
     public function __construct()
@@ -41,25 +40,25 @@  discard block
 block discarded – undo
41 40
         }
42 41
     }
43 42
     
44
-   /**
45
-    * Called whenever the application locale has changed,
46
-    * to reset the internal translation cache.
47
-    */
43
+    /**
44
+     * Called whenever the application locale has changed,
45
+     * to reset the internal translation cache.
46
+     */
48 47
     public function handle_localeChanged()
49 48
     {
50 49
         self::$texts = null;
51 50
     }
52 51
     
53
-   /**
54
-    * Converts the specified interval to a human readable
55
-    * string, e.g. "2 hours and 4 minutes".
56
-    * 
57
-    * @param \DateInterval $interval
58
-    * @return string
59
-    * @throws ConvertHelper_Exception
60
-    * 
61
-    * @see ConvertHelper_IntervalConverter::ERROR_MISSING_TRANSLATION
62
-    */
52
+    /**
53
+     * Converts the specified interval to a human readable
54
+     * string, e.g. "2 hours and 4 minutes".
55
+     * 
56
+     * @param \DateInterval $interval
57
+     * @return string
58
+     * @throws ConvertHelper_Exception
59
+     * 
60
+     * @see ConvertHelper_IntervalConverter::ERROR_MISSING_TRANSLATION
61
+     */
63 62
     public function toString(\DateInterval $interval) : string
64 63
     {
65 64
         $this->initTexts();
@@ -88,14 +87,14 @@  discard block
 block discarded – undo
88 87
         return t('%1$s and %2$s', implode(', ', $parts), $last);
89 88
     }
90 89
     
91
-   /**
92
-    * Translates the selected time token, e.g. "y" (for year).
93
-    * 
94
-    * @param string $token
95
-    * @param ConvertHelper_DateInterval $interval
96
-    * @throws ConvertHelper_Exception
97
-    * @return string
98
-    */
90
+    /**
91
+     * Translates the selected time token, e.g. "y" (for year).
92
+     * 
93
+     * @param string $token
94
+     * @param ConvertHelper_DateInterval $interval
95
+     * @throws ConvertHelper_Exception
96
+     * @return string
97
+     */
99 98
     protected function translateToken(string $token, ConvertHelper_DateInterval $interval) : string
100 99
     {
101 100
         $value = $interval->getToken($token);
@@ -123,13 +122,13 @@  discard block
 block discarded – undo
123 122
         );
124 123
     }
125 124
     
126
-   /**
127
-    * Resolves all time tokens that need to be translated in
128
-    * the subject interval, depending on its length.
129
-    * 
130
-    * @param ConvertHelper_DateInterval $interval
131
-    * @return array
132
-    */
125
+    /**
126
+     * Resolves all time tokens that need to be translated in
127
+     * the subject interval, depending on its length.
128
+     * 
129
+     * @param ConvertHelper_DateInterval $interval
130
+     * @return array
131
+     */
133 132
     protected function resolveTokens(ConvertHelper_DateInterval $interval) : array
134 133
     {
135 134
         $offset = 0;
@@ -147,9 +146,9 @@  discard block
 block discarded – undo
147 146
         return array();
148 147
     }
149 148
     
150
-   /**
151
-    * Initializes the translateable strings.
152
-    */
149
+    /**
150
+     * Initializes the translateable strings.
151
+     */
153 152
     protected function initTexts() : void
154 153
     {
155 154
         if(isset(self::$texts)) {
Please login to merge, or discard this patch.
src/URLInfo.php 2 patches
Indentation   +166 added lines, -166 removed lines patch added patch discarded remove patch
@@ -39,42 +39,42 @@  discard block
 block discarded – undo
39 39
     const TYPE_PHONE = 'phone';
40 40
     const TYPE_URL = 'url';
41 41
     
42
-   /**
43
-    * The original URL that was passed to the constructor.
44
-    * @var string
45
-    */
42
+    /**
43
+     * The original URL that was passed to the constructor.
44
+     * @var string
45
+     */
46 46
     protected $rawURL;
47 47
 
48
-   /**
49
-    * @var array
50
-    */
48
+    /**
49
+     * @var array
50
+     */
51 51
     protected $info;
52 52
     
53
-   /**
54
-    * @var string[]
55
-    */
53
+    /**
54
+     * @var string[]
55
+     */
56 56
     protected $excludedParams = array();
57 57
     
58
-   /**
59
-    * @var bool
60
-    * @see URLInfo::setParamExclusion()
61
-    */
58
+    /**
59
+     * @var bool
60
+     * @see URLInfo::setParamExclusion()
61
+     */
62 62
     protected $paramExclusion = false;
63 63
     
64
-   /**
65
-    * @var array
66
-    * @see URLInfo::getTypeLabel()
67
-    */
64
+    /**
65
+     * @var array
66
+     * @see URLInfo::getTypeLabel()
67
+     */
68 68
     protected static $typeLabels;
69 69
     
70
-   /**
71
-    * @var bool
72
-    */
70
+    /**
71
+     * @var bool
72
+     */
73 73
     protected $highlightExcluded = false;
74 74
     
75
-   /**
76
-    * @var array
77
-    */
75
+    /**
76
+     * @var array
77
+     */
78 78
     protected $infoKeys = array(
79 79
         'scheme',
80 80
         'host',
@@ -86,19 +86,19 @@  discard block
 block discarded – undo
86 86
         'fragment'
87 87
     );
88 88
     
89
-   /**
90
-    * @var string
91
-    */
89
+    /**
90
+     * @var string
91
+     */
92 92
     protected $url;
93 93
     
94
-   /**
95
-    * @var URLInfo_Parser
96
-    */
94
+    /**
95
+     * @var URLInfo_Parser
96
+     */
97 97
     protected $parser;
98 98
     
99
-   /**
100
-    * @var URLInfo_Normalizer
101
-    */
99
+    /**
100
+     * @var URLInfo_Normalizer
101
+     */
102 102
     protected $normalizer;
103 103
     
104 104
     public function __construct(string $url)
@@ -110,13 +110,13 @@  discard block
 block discarded – undo
110 110
         $this->info = $this->parser->getInfo();
111 111
     }
112 112
     
113
-   /**
114
-    * Filters an URL: removes control characters and the
115
-    * like to have a clean URL to work with.
116
-    * 
117
-    * @param string $url
118
-    * @return string
119
-    */
113
+    /**
114
+     * Filters an URL: removes control characters and the
115
+     * like to have a clean URL to work with.
116
+     * 
117
+     * @param string $url
118
+     * @return string
119
+     */
120 120
     public static function filterURL(string $url)
121 121
     {
122 122
         return URLInfo_Filter::filter($url);
@@ -146,12 +146,12 @@  discard block
 block discarded – undo
146 146
         return $this->info['type'] === self::TYPE_PHONE;
147 147
     }
148 148
     
149
-   /**
150
-    * Whether the URL is a regular URL, not one of the 
151
-    * other types like a phone number or email address.
152
-    * 
153
-    * @return bool
154
-    */
149
+    /**
150
+     * Whether the URL is a regular URL, not one of the 
151
+     * other types like a phone number or email address.
152
+     * 
153
+     * @return bool
154
+     */
155 155
     public function isURL() : bool
156 156
     {
157 157
         $host = $this->getHost();
@@ -163,20 +163,20 @@  discard block
 block discarded – undo
163 163
         return $this->parser->isValid();
164 164
     }
165 165
     
166
-   /**
167
-    * Retrieves the host name, or an empty string if none is present.
168
-    * 
169
-    * @return string
170
-    */
166
+    /**
167
+     * Retrieves the host name, or an empty string if none is present.
168
+     * 
169
+     * @return string
170
+     */
171 171
     public function getHost() : string
172 172
     {
173 173
         return $this->getInfoKey('host');
174 174
     }
175 175
     
176
-   /**
177
-    * Retrieves the path, or an empty string if none is present.
178
-    * @return string
179
-    */
176
+    /**
177
+     * Retrieves the path, or an empty string if none is present.
178
+     * @return string
179
+     */
180 180
     public function getPath() : string
181 181
     {
182 182
         return $this->getInfoKey('path');
@@ -192,10 +192,10 @@  discard block
 block discarded – undo
192 192
         return $this->getInfoKey('scheme');
193 193
     }
194 194
     
195
-   /**
196
-    * Retrieves the port specified in the URL, or -1 if none is preseent.
197
-    * @return int
198
-    */
195
+    /**
196
+     * Retrieves the port specified in the URL, or -1 if none is preseent.
197
+     * @return int
198
+     */
199 199
     public function getPort() : int
200 200
     {
201 201
         $port = $this->getInfoKey('port');
@@ -207,13 +207,13 @@  discard block
 block discarded – undo
207 207
         return -1;
208 208
     }
209 209
     
210
-   /**
211
-    * Retrieves the raw query string, or an empty string if none is present.
212
-    * 
213
-    * @return string
214
-    * 
215
-    * @see URLInfo::getParams()
216
-    */
210
+    /**
211
+     * Retrieves the raw query string, or an empty string if none is present.
212
+     * 
213
+     * @return string
214
+     * 
215
+     * @see URLInfo::getParams()
216
+     */
217 217
     public function getQuery() : string
218 218
     {
219 219
         return $this->getInfoKey('query');
@@ -229,20 +229,20 @@  discard block
 block discarded – undo
229 229
         return $this->getInfoKey('pass');
230 230
     }
231 231
     
232
-   /**
233
-    * Whether the URL contains a port number.
234
-    * @return bool
235
-    */
232
+    /**
233
+     * Whether the URL contains a port number.
234
+     * @return bool
235
+     */
236 236
     public function hasPort() : bool
237 237
     {
238 238
         return $this->getPort() !== -1;
239 239
     }
240 240
     
241
-   /**
242
-    * Alias for the hasParams() method.
243
-    * @return bool
244
-    * @see URLInfo::hasParams()
245
-    */
241
+    /**
242
+     * Alias for the hasParams() method.
243
+     * @return bool
244
+     * @see URLInfo::hasParams()
245
+     */
246 246
     public function hasQuery() : bool
247 247
     {
248 248
         return $this->hasParams();
@@ -287,23 +287,23 @@  discard block
 block discarded – undo
287 287
         return '';
288 288
     }
289 289
 
290
-   /**
291
-    * Retrieves a normalized URL: this ensures that all parameters
292
-    * in the URL are always in the same order.
293
-    * 
294
-    * @return string
295
-    */
290
+    /**
291
+     * Retrieves a normalized URL: this ensures that all parameters
292
+     * in the URL are always in the same order.
293
+     * 
294
+     * @return string
295
+     */
296 296
     public function getNormalized() : string
297 297
     {
298 298
         return $this->normalize(true);
299 299
     }
300 300
     
301
-   /**
302
-    * Like getNormalized(), but if a username and password are present
303
-    * in the URL, returns the URL without them.
304
-    * 
305
-    * @return string
306
-    */
301
+    /**
302
+     * Like getNormalized(), but if a username and password are present
303
+     * in the URL, returns the URL without them.
304
+     * 
305
+     * @return string
306
+     */
307 307
     public function getNormalizedWithoutAuth() : string
308 308
     {
309 309
         return $this->normalize(false);
@@ -324,25 +324,25 @@  discard block
 block discarded – undo
324 324
         return $this->normalizer->normalize();
325 325
     }
326 326
     
327
-   /**
328
-    * Creates a hash of the URL, which can be used for comparisons.
329
-    * Since any parameters in the URL's query are sorted alphabetically,
330
-    * the same links with a different parameter order will have the 
331
-    * same hash.
332
-    * 
333
-    * @return string
334
-    */
327
+    /**
328
+     * Creates a hash of the URL, which can be used for comparisons.
329
+     * Since any parameters in the URL's query are sorted alphabetically,
330
+     * the same links with a different parameter order will have the 
331
+     * same hash.
332
+     * 
333
+     * @return string
334
+     */
335 335
     public function getHash()
336 336
     {
337 337
         return \AppUtils\ConvertHelper::string2shortHash($this->getNormalized());
338 338
     }
339 339
 
340
-   /**
341
-    * Highlights the URL using HTML tags with specific highlighting
342
-    * class names.
343
-    * 
344
-    * @return string Will return an empty string if the URL is not valid.
345
-    */
340
+    /**
341
+     * Highlights the URL using HTML tags with specific highlighting
342
+     * class names.
343
+     * 
344
+     * @return string Will return an empty string if the URL is not valid.
345
+     */
346 346
     public function getHighlighted() : string
347 347
     {
348 348
         if(!$this->isValid()) {
@@ -376,15 +376,15 @@  discard block
 block discarded – undo
376 376
         return count($params);
377 377
     }
378 378
     
379
-   /**
380
-    * Retrieves all parameters specified in the url,
381
-    * if any, as an associative array. 
382
-    * 
383
-    * NOTE: Ignores parameters that have been added
384
-    * to the excluded parameters list.
385
-    *
386
-    * @return array
387
-    */
379
+    /**
380
+     * Retrieves all parameters specified in the url,
381
+     * if any, as an associative array. 
382
+     * 
383
+     * NOTE: Ignores parameters that have been added
384
+     * to the excluded parameters list.
385
+     *
386
+     * @return array
387
+     */
388 388
     public function getParams() : array
389 389
     {
390 390
         if(!$this->paramExclusion || empty($this->excludedParams)) {
@@ -402,22 +402,22 @@  discard block
 block discarded – undo
402 402
         return $keep;
403 403
     }
404 404
     
405
-   /**
406
-    * Retrieves the names of all parameters present in the URL, if any.
407
-    * @return string[]
408
-    */
405
+    /**
406
+     * Retrieves the names of all parameters present in the URL, if any.
407
+     * @return string[]
408
+     */
409 409
     public function getParamNames() : array
410 410
     {
411 411
         $params = $this->getParams();
412 412
         return array_keys($params);
413 413
     }
414 414
     
415
-   /**
416
-    * Retrieves a specific parameter value from the URL.
417
-    * 
418
-    * @param string $name
419
-    * @return string The parameter value, or an empty string if it does not exist.
420
-    */
415
+    /**
416
+     * Retrieves a specific parameter value from the URL.
417
+     * 
418
+     * @param string $name
419
+     * @return string The parameter value, or an empty string if it does not exist.
420
+     */
421 421
     public function getParam(string $name) : string
422 422
     {
423 423
         if(isset($this->info['params'][$name])) {
@@ -427,16 +427,16 @@  discard block
 block discarded – undo
427 427
         return '';
428 428
     }
429 429
     
430
-   /**
431
-    * Excludes an URL parameter entirely if present:
432
-    * the parser will act as if the parameter was not
433
-    * even present in the source URL, effectively
434
-    * stripping it.
435
-    *
436
-    * @param string $name
437
-    * @param string $reason A human readable explanation why this is excluded - used when highlighting links.
438
-    * @return URLInfo
439
-    */
430
+    /**
431
+     * Excludes an URL parameter entirely if present:
432
+     * the parser will act as if the parameter was not
433
+     * even present in the source URL, effectively
434
+     * stripping it.
435
+     *
436
+     * @param string $name
437
+     * @param string $reason A human readable explanation why this is excluded - used when highlighting links.
438
+     * @return URLInfo
439
+     */
440 440
     public function excludeParam(string $name, string $reason) : URLInfo
441 441
     {
442 442
         if(!isset($this->excludedParams[$name]))
@@ -489,25 +489,25 @@  discard block
 block discarded – undo
489 489
         return self::$typeLabels[$this->getType()];
490 490
     }
491 491
 
492
-   /**
493
-    * Whether excluded parameters should be highlighted in
494
-    * a different color in the URL when using the
495
-    * {@link URLInfo::getHighlighted()} method.
496
-    *
497
-    * @param bool $highlight
498
-    * @return URLInfo
499
-    */
492
+    /**
493
+     * Whether excluded parameters should be highlighted in
494
+     * a different color in the URL when using the
495
+     * {@link URLInfo::getHighlighted()} method.
496
+     *
497
+     * @param bool $highlight
498
+     * @return URLInfo
499
+     */
500 500
     public function setHighlightExcluded(bool $highlight=true) : URLInfo
501 501
     {
502 502
         $this->highlightExcluded = $highlight;
503 503
         return $this;
504 504
     }
505 505
     
506
-   /**
507
-    * Returns an array with all relevant URL information.
508
-    * 
509
-    * @return array
510
-    */
506
+    /**
507
+     * Returns an array with all relevant URL information.
508
+     * 
509
+     * @return array
510
+     */
511 511
     public function toArray() : array
512 512
     {
513 513
         return array(
@@ -551,24 +551,24 @@  discard block
 block discarded – undo
551 551
         return $this;
552 552
     }
553 553
     
554
-   /**
555
-    * Whether the parameter exclusion mode is enabled:
556
-    * In this case, if any parameters have been added to the
557
-    * exclusion list, all relevant methods will exclude these.
558
-    *
559
-    * @return bool
560
-    */
554
+    /**
555
+     * Whether the parameter exclusion mode is enabled:
556
+     * In this case, if any parameters have been added to the
557
+     * exclusion list, all relevant methods will exclude these.
558
+     *
559
+     * @return bool
560
+     */
561 561
     public function isParamExclusionEnabled() : bool
562 562
     {
563 563
         return $this->paramExclusion;
564 564
     }
565 565
     
566
-   /**
567
-    * Checks whether the link contains any parameters that
568
-    * are on the list of excluded parameters.
569
-    *
570
-    * @return bool
571
-    */
566
+    /**
567
+     * Checks whether the link contains any parameters that
568
+     * are on the list of excluded parameters.
569
+     *
570
+     * @return bool
571
+     */
572 572
     public function containsExcludedParams() : bool
573 573
     {
574 574
         if(empty($this->excludedParams)) {
@@ -636,16 +636,16 @@  discard block
 block discarded – undo
636 636
         return $this->highlightExcluded;
637 637
     }
638 638
     
639
-   /**
640
-    * Checks if the URL exists, i.e. can be connected to. Will return
641
-    * true if the returned HTTP status code is `200` or `302`.
642
-    * 
643
-    * NOTE: If the target URL requires HTTP authentication, the username
644
-    * and password should be integrated into the URL.
645
-    * 
646
-    * @return bool
647
-    * @throws BaseException
648
-    */
639
+    /**
640
+     * Checks if the URL exists, i.e. can be connected to. Will return
641
+     * true if the returned HTTP status code is `200` or `302`.
642
+     * 
643
+     * NOTE: If the target URL requires HTTP authentication, the username
644
+     * and password should be integrated into the URL.
645
+     * 
646
+     * @return bool
647
+     * @throws BaseException
648
+     */
649 649
     public function tryConnect(bool $verifySSL=true) : bool
650 650
     {
651 651
         requireCURL();
Please login to merge, or discard this patch.
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
     {
201 201
         $port = $this->getInfoKey('port');
202 202
         
203
-        if(!empty($port)) {
203
+        if (!empty($port)) {
204 204
             return (int)$port;
205 205
         }
206 206
         
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
     
281 281
     protected function getInfoKey(string $name) : string
282 282
     {
283
-        if(isset($this->info[$name])) {
283
+        if (isset($this->info[$name])) {
284 284
             return (string)$this->info[$name];
285 285
         }
286 286
         
@@ -309,13 +309,13 @@  discard block
 block discarded – undo
309 309
         return $this->normalize(false);
310 310
     }
311 311
     
312
-    protected function normalize(bool $auth=true) : string
312
+    protected function normalize(bool $auth = true) : string
313 313
     {
314
-        if(!$this->isValid()) {
314
+        if (!$this->isValid()) {
315 315
             return '';
316 316
         }
317 317
         
318
-        if(!isset($this->normalizer)) {
318
+        if (!isset($this->normalizer)) {
319 319
             $this->normalizer = new URLInfo_Normalizer($this);
320 320
         }
321 321
         
@@ -345,7 +345,7 @@  discard block
 block discarded – undo
345 345
     */
346 346
     public function getHighlighted() : string
347 347
     {
348
-        if(!$this->isValid()) {
348
+        if (!$this->isValid()) {
349 349
             return '';
350 350
         }
351 351
         
@@ -387,14 +387,14 @@  discard block
 block discarded – undo
387 387
     */
388 388
     public function getParams() : array
389 389
     {
390
-        if(!$this->paramExclusion || empty($this->excludedParams)) {
390
+        if (!$this->paramExclusion || empty($this->excludedParams)) {
391 391
             return $this->info['params'];
392 392
         }
393 393
         
394 394
         $keep = array();
395
-        foreach($this->info['params'] as $name => $value) 
395
+        foreach ($this->info['params'] as $name => $value) 
396 396
         {
397
-            if(!isset($this->excludedParams[$name])) {
397
+            if (!isset($this->excludedParams[$name])) {
398 398
                 $keep[$name] = $value;
399 399
             }
400 400
         }
@@ -420,7 +420,7 @@  discard block
 block discarded – undo
420 420
     */
421 421
     public function getParam(string $name) : string
422 422
     {
423
-        if(isset($this->info['params'][$name])) {
423
+        if (isset($this->info['params'][$name])) {
424 424
             return $this->info['params'][$name];
425 425
         }
426 426
         
@@ -439,7 +439,7 @@  discard block
 block discarded – undo
439 439
     */
440 440
     public function excludeParam(string $name, string $reason) : URLInfo
441 441
     {
442
-        if(!isset($this->excludedParams[$name]))
442
+        if (!isset($this->excludedParams[$name]))
443 443
         {
444 444
             $this->excludedParams[$name] = $reason;
445 445
             $this->setParamExclusion();
@@ -465,7 +465,7 @@  discard block
 block discarded – undo
465 465
     
466 466
     public function getTypeLabel() : string
467 467
     {
468
-        if(!isset(self::$typeLabels))
468
+        if (!isset(self::$typeLabels))
469 469
         {
470 470
             self::$typeLabels = array(
471 471
                 self::TYPE_EMAIL => t('Email'),
@@ -477,7 +477,7 @@  discard block
 block discarded – undo
477 477
         
478 478
         $type = $this->getType();
479 479
         
480
-        if(!isset(self::$typeLabels[$type]))
480
+        if (!isset(self::$typeLabels[$type]))
481 481
         {
482 482
             throw new BaseException(
483 483
                 sprintf('Unknown URL type label for type [%s].', $type),
@@ -497,7 +497,7 @@  discard block
 block discarded – undo
497 497
     * @param bool $highlight
498 498
     * @return URLInfo
499 499
     */
500
-    public function setHighlightExcluded(bool $highlight=true) : URLInfo
500
+    public function setHighlightExcluded(bool $highlight = true) : URLInfo
501 501
     {
502 502
         $this->highlightExcluded = $highlight;
503 503
         return $this;
@@ -545,7 +545,7 @@  discard block
 block discarded – undo
545 545
      * @see URLInfo::isParamExclusionEnabled()
546 546
      * @see URLInfo::setHighlightExcluded()
547 547
      */
548
-    public function setParamExclusion(bool $enabled=true) : URLInfo
548
+    public function setParamExclusion(bool $enabled = true) : URLInfo
549 549
     {
550 550
         $this->paramExclusion = $enabled;
551 551
         return $this;
@@ -571,13 +571,13 @@  discard block
 block discarded – undo
571 571
     */
572 572
     public function containsExcludedParams() : bool
573 573
     {
574
-        if(empty($this->excludedParams)) {
574
+        if (empty($this->excludedParams)) {
575 575
             return false;
576 576
         }
577 577
         
578 578
         $names = array_keys($this->info['params']);
579
-        foreach($names as $name) {
580
-            if(isset($this->excludedParams[$name])) {
579
+        foreach ($names as $name) {
580
+            if (isset($this->excludedParams[$name])) {
581 581
                 return true;
582 582
             }
583 583
         }
@@ -593,7 +593,7 @@  discard block
 block discarded – undo
593 593
 
594 594
     public function offsetSet($offset, $value) 
595 595
     {
596
-        if(in_array($offset, $this->infoKeys)) {
596
+        if (in_array($offset, $this->infoKeys)) {
597 597
             $this->info[$offset] = $value;
598 598
         }
599 599
     }
@@ -610,11 +610,11 @@  discard block
 block discarded – undo
610 610
     
611 611
     public function offsetGet($offset) 
612 612
     {
613
-        if($offset === 'port') {
613
+        if ($offset === 'port') {
614 614
             return $this->getPort();
615 615
         }
616 616
         
617
-        if(in_array($offset, $this->infoKeys)) {
617
+        if (in_array($offset, $this->infoKeys)) {
618 618
             return $this->getInfoKey($offset);
619 619
         }
620 620
         
@@ -646,12 +646,12 @@  discard block
 block discarded – undo
646 646
     * @return bool
647 647
     * @throws BaseException
648 648
     */
649
-    public function tryConnect(bool $verifySSL=true) : bool
649
+    public function tryConnect(bool $verifySSL = true) : bool
650 650
     {
651 651
         requireCURL();
652 652
         
653 653
         $ch = curl_init();
654
-        if(!is_resource($ch))
654
+        if (!is_resource($ch))
655 655
         {
656 656
             throw new BaseException(
657 657
                 'Could not initialize a new cURL instance.',
@@ -667,13 +667,13 @@  discard block
 block discarded – undo
667 667
         curl_setopt($ch, CURLOPT_TIMEOUT, 10);
668 668
         curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
669 669
         
670
-        if(!$verifySSL) 
670
+        if (!$verifySSL) 
671 671
         {
672 672
             curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
673 673
             curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
674 674
         }
675 675
         
676
-        if($this->hasUsername()) 
676
+        if ($this->hasUsername()) 
677 677
         {
678 678
             curl_setopt($ch, CURLOPT_USERNAME, $this->getUsername());
679 679
             curl_setopt($ch, CURLOPT_PASSWORD, $this->getPassword());
Please login to merge, or discard this patch.
src/RequestHelper.php 3 patches
Indentation   +96 added lines, -96 removed lines patch added patch discarded remove patch
@@ -29,56 +29,56 @@  discard block
 block discarded – undo
29 29
     
30 30
     const ERROR_CURL_INIT_FAILED = 17903;
31 31
 
32
-   /**
33
-    * @var string
34
-    */
32
+    /**
33
+     * @var string
34
+     */
35 35
     protected $eol = "\r\n";
36 36
 
37
-   /**
38
-    * @var string
39
-    */
37
+    /**
38
+     * @var string
39
+     */
40 40
     protected $mimeBoundary;
41 41
 
42
-   /**
43
-    * @var string
44
-    */
42
+    /**
43
+     * @var string
44
+     */
45 45
     protected $data = '';
46 46
 
47
-   /**
48
-    * @var string
49
-    */
47
+    /**
48
+     * @var string
49
+     */
50 50
     protected $destination;
51 51
 
52
-   /**
53
-    * @var array
54
-    */
52
+    /**
53
+     * @var array
54
+     */
55 55
     protected $headers = array();
56 56
     
57
-   /**
58
-    * Whether to verify SSL certificates.
59
-    * @var bool
60
-    */
57
+    /**
58
+     * Whether to verify SSL certificates.
59
+     * @var bool
60
+     */
61 61
     protected $verifySSL = true;
62 62
     
63
-   /**
64
-    * @var RequestHelper_Boundaries
65
-    */
63
+    /**
64
+     * @var RequestHelper_Boundaries
65
+     */
66 66
     protected $boundaries;
67 67
     
68
-   /**
69
-    * @var RequestHelper_Response|NULL
70
-    */
68
+    /**
69
+     * @var RequestHelper_Response|NULL
70
+     */
71 71
     protected $response;
72 72
 
73
-   /**
74
-    * @var integer
75
-    */
73
+    /**
74
+     * @var integer
75
+     */
76 76
     protected $timeout = 30;
77 77
     
78
-   /**
79
-    * Creates a new request helper to send POST data to the specified destination URL.
80
-    * @param string $destinationURL
81
-    */
78
+    /**
79
+     * Creates a new request helper to send POST data to the specified destination URL.
80
+     * @param string $destinationURL
81
+     */
82 82
     public function __construct(string $destinationURL)
83 83
     {
84 84
         $this->destination = $destinationURL;
@@ -105,15 +105,15 @@  discard block
 block discarded – undo
105 105
         return $this;
106 106
     }
107 107
 
108
-   /**
109
-    * Adds a file to be sent with the request.
110
-    *
111
-    * @param string $varName The variable name to send the file in
112
-    * @param string $fileName The name of the file as it should be received at the destination
113
-    * @param string $content The raw content of the file
114
-    * @param string $contentType The content type, use the constants to specify this
115
-    * @param string $encoding The encoding of the file, use the constants to specify this
116
-    */
108
+    /**
109
+     * Adds a file to be sent with the request.
110
+     *
111
+     * @param string $varName The variable name to send the file in
112
+     * @param string $fileName The name of the file as it should be received at the destination
113
+     * @param string $content The raw content of the file
114
+     * @param string $contentType The content type, use the constants to specify this
115
+     * @param string $encoding The encoding of the file, use the constants to specify this
116
+     */
117 117
     public function addFile(string $varName, string $fileName, string $content, string $contentType = self::FILETYPE_TEXT, string $encoding = self::ENCODING_UTF8) : RequestHelper
118 118
     {
119 119
         $this->boundaries->addFile($varName, $fileName, $content, $contentType, $encoding);
@@ -121,13 +121,13 @@  discard block
 block discarded – undo
121 121
         return $this;
122 122
     }
123 123
     
124
-   /**
125
-    * Adds arbitrary content.
126
-    * 
127
-    * @param string $varName The variable name to send the content in.
128
-    * @param string $content
129
-    * @param string $contentType
130
-    */
124
+    /**
125
+     * Adds arbitrary content.
126
+     * 
127
+     * @param string $varName The variable name to send the content in.
128
+     * @param string $content
129
+     * @param string $contentType
130
+     */
131 131
     public function addContent(string $varName, string $content, string $contentType) : RequestHelper
132 132
     {
133 133
         $this->boundaries->addContent($varName, $content, $contentType);
@@ -149,13 +149,13 @@  discard block
 block discarded – undo
149 149
         return $this;
150 150
     }
151 151
     
152
-   /**
153
-    * Sets an HTTP header to include in the request.
154
-    * 
155
-    * @param string $name
156
-    * @param string $value
157
-    * @return RequestHelper
158
-    */
152
+    /**
153
+     * Sets an HTTP header to include in the request.
154
+     * 
155
+     * @param string $name
156
+     * @param string $value
157
+     * @return RequestHelper
158
+     */
159 159
     public function setHeader(string $name, string $value) : RequestHelper
160 160
     {
161 161
         $this->headers[$name] = $value;
@@ -163,36 +163,36 @@  discard block
 block discarded – undo
163 163
         return $this;
164 164
     }
165 165
     
166
-   /**
167
-    * Disables SSL certificate checking.
168
-    * 
169
-    * @return RequestHelper
170
-    */
166
+    /**
167
+     * Disables SSL certificate checking.
168
+     * 
169
+     * @return RequestHelper
170
+     */
171 171
     public function disableSSLChecks() : RequestHelper
172 172
     {
173 173
         $this->verifySSL = false;
174 174
         return $this;
175 175
     }
176 176
    
177
-   /**
178
-    * @var integer
179
-    */
177
+    /**
178
+     * @var integer
179
+     */
180 180
     protected $contentLength = 0;
181 181
 
182
-   /**
183
-    * Sends the POST request to the destination, and returns
184
-    * the response text.
185
-    *
186
-    * The response object is stored internally, so after calling
187
-    * this method it may be retrieved at any moment using the
188
-    * {@link getResponse()} method.
189
-    *
190
-    * @return string
191
-    * @see RequestHelper::getResponse()
192
-    * @throws RequestHelper_Exception
193
-    * 
194
-    * @see RequestHelper::ERROR_REQUEST_FAILED
195
-    */
182
+    /**
183
+     * Sends the POST request to the destination, and returns
184
+     * the response text.
185
+     *
186
+     * The response object is stored internally, so after calling
187
+     * this method it may be retrieved at any moment using the
188
+     * {@link getResponse()} method.
189
+     *
190
+     * @return string
191
+     * @see RequestHelper::getResponse()
192
+     * @throws RequestHelper_Exception
193
+     * 
194
+     * @see RequestHelper::ERROR_REQUEST_FAILED
195
+     */
196 196
     public function send() : string
197 197
     {
198 198
         $this->data = $this->boundaries->render();
@@ -232,14 +232,14 @@  discard block
 block discarded – undo
232 232
         return $this->data;
233 233
     }
234 234
     
235
-   /**
236
-    * Creates a new CURL resource configured according to the
237
-    * request's settings.
238
-    * 
239
-    * @param URLInfo $url
240
-    * @throws RequestHelper_Exception
241
-    * @return resource
242
-    */
235
+    /**
236
+     * Creates a new CURL resource configured according to the
237
+     * request's settings.
238
+     * 
239
+     * @param URLInfo $url
240
+     * @throws RequestHelper_Exception
241
+     * @return resource
242
+     */
243 243
     protected function createCURL(URLInfo $url)
244 244
     {
245 245
         $ch = curl_init();
@@ -279,13 +279,13 @@  discard block
 block discarded – undo
279 279
         return $ch;
280 280
     }
281 281
 
282
-   /**
283
-    * Compiles the associative headers array into
284
-    * the format understood by CURL, namely an indexed
285
-    * array with one header string per entry.
286
-    * 
287
-    * @return array
288
-    */
282
+    /**
283
+     * Compiles the associative headers array into
284
+     * the format understood by CURL, namely an indexed
285
+     * array with one header string per entry.
286
+     * 
287
+     * @return array
288
+     */
289 289
     protected function renderHeaders() : array
290 290
     {
291 291
         $result = array();
@@ -297,10 +297,10 @@  discard block
 block discarded – undo
297 297
         return $result;
298 298
     }
299 299
     
300
-   /**
301
-    * Retrieves the raw response header, in the form of an indexed
302
-    * array containing all response header lines, for example:
303
-    */
300
+    /**
301
+     * Retrieves the raw response header, in the form of an indexed
302
+     * array containing all response header lines, for example:
303
+     */
304 304
     public function getResponseHeader() : array
305 305
     {
306 306
         if(isset($this->response)) {
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
         // CURL will complain about an empty response when the 
211 211
         // server sends a 100-continue code. That should not be
212 212
         // regarded as an error.
213
-        if($output === false && $this->response->getCode() !== 100)
213
+        if ($output === false && $this->response->getCode() !== 100)
214 214
         {
215 215
             $this->response->setError(
216 216
                 curl_errno($ch),
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
     protected function createCURL(URLInfo $url)
244 244
     {
245 245
         $ch = curl_init();
246
-        if(!is_resource($ch))
246
+        if (!is_resource($ch))
247 247
         {
248 248
             throw new RequestHelper_Exception(
249 249
                 'Could not initialize a new cURL instance.',
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
         }
254 254
 
255 255
         $this->setHeader('Content-Length', (string)$this->boundaries->getContentLength());
256
-        $this->setHeader('Content-Type', 'multipart/form-data; charset=UTF-8; boundary=' . $this->mimeBoundary);
256
+        $this->setHeader('Content-Type', 'multipart/form-data; charset=UTF-8; boundary='.$this->mimeBoundary);
257 257
         
258 258
         //curl_setopt($ch, CURLOPT_VERBOSE, true);
259 259
         curl_setopt($ch, CURLOPT_POST, true);
@@ -264,13 +264,13 @@  discard block
 block discarded – undo
264 264
         curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
265 265
         curl_setopt($ch, CURLOPT_HTTPHEADER, $this->renderHeaders());
266 266
         
267
-        if($this->verifySSL)
267
+        if ($this->verifySSL)
268 268
         {
269 269
             curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
270 270
             curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
271 271
         }
272 272
         
273
-        if($url->hasUsername())
273
+        if ($url->hasUsername())
274 274
         {
275 275
             curl_setopt($ch, CURLOPT_USERNAME, $url->getUsername());
276 276
             curl_setopt($ch, CURLOPT_PASSWORD, $url->getPassword());
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
     {
291 291
         $result = array();
292 292
         
293
-        foreach($this->headers as $name => $value) {
293
+        foreach ($this->headers as $name => $value) {
294 294
             $result[] = $name.': '.$value;
295 295
         }
296 296
         
@@ -303,7 +303,7 @@  discard block
 block discarded – undo
303 303
     */
304 304
     public function getResponseHeader() : array
305 305
     {
306
-        if(isset($this->response)) {
306
+        if (isset($this->response)) {
307 307
             return $this->response->getHeaders();
308 308
         }
309 309
 
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -216,8 +216,7 @@
 block discarded – undo
216 216
                 curl_errno($ch),
217 217
                 curl_error($ch)
218 218
             );
219
-        }
220
-        else
219
+        } else
221 220
         {
222 221
             $this->response->setBody((string)$output);
223 222
         }
Please login to merge, or discard this patch.
src/ConvertHelper.php 2 patches
Indentation   +453 added lines, -453 removed lines patch added patch discarded remove patch
@@ -162,41 +162,41 @@  discard block
 block discarded – undo
162 162
         return implode(', ', $tokens) . ' ' . t('and') . ' ' . $last;
163 163
     }
164 164
 
165
-   /**
166
-    * Converts a timestamp into an easily understandable
167
-    * format, e.g. "2 hours", "1 day", "3 months"
168
-    *
169
-    * If you set the date to parameter, the difference
170
-    * will be calculated between the two dates and not
171
-    * the current time.
172
-    *
173
-    * @param integer|\DateTime $datefrom
174
-    * @param integer|\DateTime $dateto
175
-    * @return string
176
-    */
165
+    /**
166
+     * Converts a timestamp into an easily understandable
167
+     * format, e.g. "2 hours", "1 day", "3 months"
168
+     *
169
+     * If you set the date to parameter, the difference
170
+     * will be calculated between the two dates and not
171
+     * the current time.
172
+     *
173
+     * @param integer|\DateTime $datefrom
174
+     * @param integer|\DateTime $dateto
175
+     * @return string
176
+     */
177 177
     public static function duration2string($datefrom, $dateto = -1) : string
178 178
     {
179
-         $converter = new ConvertHelper_DurationConverter();
179
+            $converter = new ConvertHelper_DurationConverter();
180 180
          
181
-         if($datefrom instanceof \DateTime)
182
-         {
183
-             $converter->setDateFrom($datefrom);
184
-         }
185
-         else
186
-         {
187
-             $converter->setDateFrom(self::timestamp2date($datefrom)); 
188
-         }
181
+            if($datefrom instanceof \DateTime)
182
+            {
183
+                $converter->setDateFrom($datefrom);
184
+            }
185
+            else
186
+            {
187
+                $converter->setDateFrom(self::timestamp2date($datefrom)); 
188
+            }
189 189
 
190
-         if($dateto instanceof \DateTime)
191
-         {
192
-             $converter->setDateTo($dateto);
193
-         }
194
-         else if($dateto > 0)
195
-         {
196
-             $converter->setDateTo(self::timestamp2date($dateto));
197
-         }
190
+            if($dateto instanceof \DateTime)
191
+            {
192
+                $converter->setDateTo($dateto);
193
+            }
194
+            else if($dateto > 0)
195
+            {
196
+                $converter->setDateTo(self::timestamp2date($dateto));
197
+            }
198 198
 
199
-         return $converter->convert();
199
+            return $converter->convert();
200 200
     }
201 201
 
202 202
     /**
@@ -235,44 +235,44 @@  discard block
 block discarded – undo
235 235
         return $geshi->parse_code();
236 236
     }
237 237
     
238
-   /**
239
-    * Converts a number of bytes to a human readable form,
240
-    * e.g. xx Kb / xx Mb / xx Gb
241
-    *
242
-    * @param int $bytes The amount of bytes to convert.
243
-    * @param int $precision The amount of decimals
244
-    * @param int $base The base to calculate with: Base 10 is default (=1000 Bytes in a KB), Base 2 is mainly used for Windows memory (=1024 Bytes in a KB).
245
-    * @return string
246
-    * 
247
-    * @see https://en.m.wikipedia.org/wiki/Megabyte#Definitions
248
-    */
238
+    /**
239
+     * Converts a number of bytes to a human readable form,
240
+     * e.g. xx Kb / xx Mb / xx Gb
241
+     *
242
+     * @param int $bytes The amount of bytes to convert.
243
+     * @param int $precision The amount of decimals
244
+     * @param int $base The base to calculate with: Base 10 is default (=1000 Bytes in a KB), Base 2 is mainly used for Windows memory (=1024 Bytes in a KB).
245
+     * @return string
246
+     * 
247
+     * @see https://en.m.wikipedia.org/wiki/Megabyte#Definitions
248
+     */
249 249
     public static function bytes2readable(int $bytes, int $precision = 1, int $base = ConvertHelper_StorageSizeEnum::BASE_10) : string
250 250
     {
251 251
         return self::parseBytes($bytes)->toString($precision, $base);
252 252
     }
253 253
     
254
-   /**
255
-    * Parses a number of bytes, and creates a converter instance which
256
-    * allows doing common operations with it.
257
-    * 
258
-    * @param int $bytes
259
-    * @return ConvertHelper_ByteConverter
260
-    */
254
+    /**
255
+     * Parses a number of bytes, and creates a converter instance which
256
+     * allows doing common operations with it.
257
+     * 
258
+     * @param int $bytes
259
+     * @return ConvertHelper_ByteConverter
260
+     */
261 261
     public static function parseBytes(int $bytes) : ConvertHelper_ByteConverter
262 262
     {
263 263
         return new ConvertHelper_ByteConverter($bytes);
264 264
     }
265 265
 
266
-   /**
267
-    * Cuts a text to the specified length if it is longer than the
268
-    * target length. Appends a text to signify it has been cut at 
269
-    * the end of the string.
270
-    * 
271
-    * @param string $text
272
-    * @param int $targetLength
273
-    * @param string $append
274
-    * @return string
275
-    */
266
+    /**
267
+     * Cuts a text to the specified length if it is longer than the
268
+     * target length. Appends a text to signify it has been cut at 
269
+     * the end of the string.
270
+     * 
271
+     * @param string $text
272
+     * @param int $targetLength
273
+     * @param string $append
274
+     * @return string
275
+     */
276 276
     public static function text_cut(string $text, int $targetLength, string $append = '...') : string
277 277
     {
278 278
         $length = mb_strlen($text);
@@ -296,14 +296,14 @@  discard block
 block discarded – undo
296 296
         return $info->toString();
297 297
     }
298 298
     
299
-   /**
300
-    * Pretty print_r.
301
-    * 
302
-    * @param mixed $var The variable to dump.
303
-    * @param bool $return Whether to return the dumped code.
304
-    * @param bool $html Whether to style the dump as HTML.
305
-    * @return string
306
-    */
299
+    /**
300
+     * Pretty print_r.
301
+     * 
302
+     * @param mixed $var The variable to dump.
303
+     * @param bool $return Whether to return the dumped code.
304
+     * @param bool $html Whether to style the dump as HTML.
305
+     * @return string
306
+     */
307 307
     public static function print_r($var, bool $return=false, bool $html=true) : string
308 308
     {
309 309
         $result = parseVariable($var)->enableType()->toString();
@@ -333,15 +333,15 @@  discard block
 block discarded – undo
333 333
         'no' => false
334 334
     );
335 335
 
336
-   /**
337
-    * Converts a string, number or boolean value to a boolean value.
338
-    * 
339
-    * @param mixed $string
340
-    * @throws ConvertHelper_Exception
341
-    * @return bool
342
-    * 
343
-    * @see ConvertHelper::ERROR_INVALID_BOOLEAN_STRING
344
-    */
336
+    /**
337
+     * Converts a string, number or boolean value to a boolean value.
338
+     * 
339
+     * @param mixed $string
340
+     * @throws ConvertHelper_Exception
341
+     * @return bool
342
+     * 
343
+     * @see ConvertHelper::ERROR_INVALID_BOOLEAN_STRING
344
+     */
345 345
     public static function string2bool($string) : bool
346 346
     {
347 347
         if($string === '' || $string === null || !is_scalar($string)) 
@@ -369,27 +369,27 @@  discard block
 block discarded – undo
369 369
         );
370 370
     }
371 371
     
372
-   /**
373
-    * Whether the specified string is a boolean string or boolean value.
374
-    * Alias for {@link ConvertHelper::isBoolean()}.
375
-    * 
376
-    * @param mixed $string
377
-    * @return bool
378
-    * @deprecated
379
-    * @see ConvertHelper::isBoolean()
380
-    */
372
+    /**
373
+     * Whether the specified string is a boolean string or boolean value.
374
+     * Alias for {@link ConvertHelper::isBoolean()}.
375
+     * 
376
+     * @param mixed $string
377
+     * @return bool
378
+     * @deprecated
379
+     * @see ConvertHelper::isBoolean()
380
+     */
381 381
     public static function isBooleanString($string) : bool
382 382
     {
383 383
         return self::isBoolean($string);
384 384
     }
385 385
 
386
-   /**
387
-    * Alias for the {@\AppUtils\XMLHelper::string2xml()} method.
388
-    * 
389
-    * @param string $text
390
-    * @return string
391
-    * @deprecated
392
-    */
386
+    /**
387
+     * Alias for the {@\AppUtils\XMLHelper::string2xml()} method.
388
+     * 
389
+     * @param string $text
390
+     * @return string
391
+     * @deprecated
392
+     */
393 393
     public static function text_makeXMLCompliant($text)
394 394
     {
395 395
         return XMLHelper::string2xml($text);
@@ -491,13 +491,13 @@  discard block
 block discarded – undo
491 491
         return $translit->convert($string);
492 492
     }
493 493
     
494
-   /**
495
-    * Retrieves the HEX character codes for all control
496
-    * characters that the {@link stripControlCharacters()} 
497
-    * method will remove.
498
-    * 
499
-    * @return string[]
500
-    */
494
+    /**
495
+     * Retrieves the HEX character codes for all control
496
+     * characters that the {@link stripControlCharacters()} 
497
+     * method will remove.
498
+     * 
499
+     * @return string[]
500
+     */
501 501
     public static function getControlCharactersAsHex()
502 502
     {
503 503
         $hexAlphabet = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F');
@@ -533,13 +533,13 @@  discard block
 block discarded – undo
533 533
         return $stack;
534 534
     }
535 535
     
536
-   /**
537
-    * Retrieves an array of all control characters that
538
-    * the {@link stripControlCharacters()} method will 
539
-    * remove, as the actual UTF-8 characters.
540
-    * 
541
-    * @return string[]
542
-    */
536
+    /**
537
+     * Retrieves an array of all control characters that
538
+     * the {@link stripControlCharacters()} method will 
539
+     * remove, as the actual UTF-8 characters.
540
+     * 
541
+     * @return string[]
542
+     */
543 543
     public static function getControlCharactersAsUTF8()
544 544
     {
545 545
         $chars = self::getControlCharactersAsHex();
@@ -552,12 +552,12 @@  discard block
 block discarded – undo
552 552
         return $result;
553 553
     }
554 554
     
555
-   /**
556
-    * Retrieves all control characters as JSON encoded
557
-    * characters, e.g. "\u200b".
558
-    * 
559
-    * @return string[]
560
-    */
555
+    /**
556
+     * Retrieves all control characters as JSON encoded
557
+     * characters, e.g. "\u200b".
558
+     * 
559
+     * @return string[]
560
+     */
561 561
     public static function getControlCharactersAsJSON()
562 562
     {
563 563
         $chars = self::getControlCharactersAsHex();
@@ -614,20 +614,20 @@  discard block
 block discarded – undo
614 614
         return preg_replace(self::$controlCharsRegex, '', $string);
615 615
     }
616 616
 
617
-   /**
618
-    * Converts a unicode character to the PHPO notation.
619
-    * 
620
-    * Example:
621
-    * 
622
-    * <pre>unicodeChar2php('"\u0000"')</pre>
623
-    * 
624
-    * Returns
625
-    * 
626
-    * <pre>\x0</pre>
627
-    * 
628
-    * @param string $unicodeChar
629
-    * @return string
630
-    */
617
+    /**
618
+     * Converts a unicode character to the PHPO notation.
619
+     * 
620
+     * Example:
621
+     * 
622
+     * <pre>unicodeChar2php('"\u0000"')</pre>
623
+     * 
624
+     * Returns
625
+     * 
626
+     * <pre>\x0</pre>
627
+     * 
628
+     * @param string $unicodeChar
629
+     * @return string
630
+     */
631 631
     public static function unicodeChar2php(string $unicodeChar) : string 
632 632
     {
633 633
         $unicodeChar = json_decode($unicodeChar);
@@ -753,25 +753,25 @@  discard block
 block discarded – undo
753 753
         return 'false';
754 754
     }
755 755
     
756
-   /**
757
-    * Converts an associative array with attribute name > value pairs
758
-    * to an attribute string that can be used in an HTML tag. Empty 
759
-    * attribute values are ignored.
760
-    * 
761
-    * Example:
762
-    * 
763
-    * array2attributeString(array(
764
-    *     'id' => 45,
765
-    *     'href' => 'http://www.mistralys.com'
766
-    * ));
767
-    * 
768
-    * Result:
769
-    * 
770
-    * id="45" href="http://www.mistralys.com"
771
-    * 
772
-    * @param array $array
773
-    * @return string
774
-    */
756
+    /**
757
+     * Converts an associative array with attribute name > value pairs
758
+     * to an attribute string that can be used in an HTML tag. Empty 
759
+     * attribute values are ignored.
760
+     * 
761
+     * Example:
762
+     * 
763
+     * array2attributeString(array(
764
+     *     'id' => 45,
765
+     *     'href' => 'http://www.mistralys.com'
766
+     * ));
767
+     * 
768
+     * Result:
769
+     * 
770
+     * id="45" href="http://www.mistralys.com"
771
+     * 
772
+     * @param array $array
773
+     * @return string
774
+     */
775 775
     public static function array2attributeString($array)
776 776
     {
777 777
         $tokens = array();
@@ -790,14 +790,14 @@  discard block
 block discarded – undo
790 790
         return ' '.implode(' ', $tokens);
791 791
     }
792 792
     
793
-   /**
794
-    * Converts a string so it can safely be used in a javascript
795
-    * statement in an HTML tag: uses single quotes around the string
796
-    * and encodes all special characters as needed.
797
-    * 
798
-    * @param string $string
799
-    * @return string
800
-    */
793
+    /**
794
+     * Converts a string so it can safely be used in a javascript
795
+     * statement in an HTML tag: uses single quotes around the string
796
+     * and encodes all special characters as needed.
797
+     * 
798
+     * @param string $string
799
+     * @return string
800
+     */
801 801
     public static function string2attributeJS($string, $quoted=true)
802 802
     {
803 803
         $converted = addslashes(htmlspecialchars(strip_tags($string), ENT_QUOTES, 'UTF-8'));
@@ -808,15 +808,15 @@  discard block
 block discarded – undo
808 808
         return $converted;
809 809
     }
810 810
     
811
-   /**
812
-    * Checks if the specified string is a boolean value, which
813
-    * includes string representations of boolean values, like 
814
-    * <code>yes</code> or <code>no</code>, and <code>true</code>
815
-    * or <code>false</code>.
816
-    * 
817
-    * @param mixed $value
818
-    * @return boolean
819
-    */
811
+    /**
812
+     * Checks if the specified string is a boolean value, which
813
+     * includes string representations of boolean values, like 
814
+     * <code>yes</code> or <code>no</code>, and <code>true</code>
815
+     * or <code>false</code>.
816
+     * 
817
+     * @param mixed $value
818
+     * @return boolean
819
+     */
820 820
     public static function isBoolean($value) : bool
821 821
     {
822 822
         if(is_bool($value)) {
@@ -830,12 +830,12 @@  discard block
 block discarded – undo
830 830
         return array_key_exists($value, self::$booleanStrings);
831 831
     }
832 832
     
833
-   /**
834
-    * Converts an associative array to an HTML style attribute value string.
835
-    * 
836
-    * @param array $subject
837
-    * @return string
838
-    */
833
+    /**
834
+     * Converts an associative array to an HTML style attribute value string.
835
+     * 
836
+     * @param array $subject
837
+     * @return string
838
+     */
839 839
     public static function array2styleString(array $subject) : string
840 840
     {
841 841
         $tokens = array();
@@ -846,23 +846,23 @@  discard block
 block discarded – undo
846 846
         return implode(';', $tokens);
847 847
     }
848 848
     
849
-   /**
850
-    * Converts a DateTime object to a timestamp, which
851
-    * is PHP 5.2 compatible.
852
-    * 
853
-    * @param \DateTime $date
854
-    * @return integer
855
-    */
849
+    /**
850
+     * Converts a DateTime object to a timestamp, which
851
+     * is PHP 5.2 compatible.
852
+     * 
853
+     * @param \DateTime $date
854
+     * @return integer
855
+     */
856 856
     public static function date2timestamp(\DateTime $date) : int
857 857
     {
858 858
         return (int)$date->format('U');
859 859
     }
860 860
     
861
-   /**
862
-    * Converts a timestamp into a DateTime instance.
863
-    * @param int $timestamp
864
-    * @return \DateTime
865
-    */
861
+    /**
862
+     * Converts a timestamp into a DateTime instance.
863
+     * @param int $timestamp
864
+     * @return \DateTime
865
+     */
866 866
     public static function timestamp2date(int $timestamp) : \DateTime
867 867
     {
868 868
         $date = new \DateTime();
@@ -870,50 +870,50 @@  discard block
 block discarded – undo
870 870
         return $date;
871 871
     }
872 872
     
873
-   /**
874
-    * Strips an absolute path to a file within the application
875
-    * to make the path relative to the application root path.
876
-    * 
877
-    * @param string $path
878
-    * @return string
879
-    * 
880
-    * @see FileHelper::relativizePath()
881
-    * @see FileHelper::relativizePathByDepth()
882
-    */
873
+    /**
874
+     * Strips an absolute path to a file within the application
875
+     * to make the path relative to the application root path.
876
+     * 
877
+     * @param string $path
878
+     * @return string
879
+     * 
880
+     * @see FileHelper::relativizePath()
881
+     * @see FileHelper::relativizePathByDepth()
882
+     */
883 883
     public static function fileRelativize(string $path) : string
884 884
     {
885 885
         return FileHelper::relativizePathByDepth($path);
886 886
     }
887 887
     
888 888
     /**
889
-    * Converts a PHP regex to a javascript RegExp object statement.
890
-    * 
891
-    * NOTE: This is an alias for the JSHelper's `convertRegex` method. 
892
-    * More details are available on its usage there.
893
-    *
894
-    * @param string $regex A PHP preg regex
895
-    * @param string $statementType The type of statement to return: Defaults to a statement to create a RegExp object.
896
-    * @return array|string Depending on the specified return type.
897
-    * 
898
-    * @see JSHelper::buildRegexStatement()
899
-    */
889
+     * Converts a PHP regex to a javascript RegExp object statement.
890
+     * 
891
+     * NOTE: This is an alias for the JSHelper's `convertRegex` method. 
892
+     * More details are available on its usage there.
893
+     *
894
+     * @param string $regex A PHP preg regex
895
+     * @param string $statementType The type of statement to return: Defaults to a statement to create a RegExp object.
896
+     * @return array|string Depending on the specified return type.
897
+     * 
898
+     * @see JSHelper::buildRegexStatement()
899
+     */
900 900
     public static function regex2js(string $regex, string $statementType=JSHelper::JS_REGEX_OBJECT)
901 901
     {
902 902
         return JSHelper::buildRegexStatement($regex, $statementType);
903 903
     }
904 904
     
905
-   /**
906
-    * Converts the specified variable to JSON. Works just
907
-    * like the native `json_encode` method, except that it
908
-    * will trigger an exception on failure, which has the 
909
-    * json error details included in its developer details.
910
-    * 
911
-    * @param mixed $variable
912
-    * @param int $options JSON encode options.
913
-    * @param int $depth 
914
-    * @throws ConvertHelper_Exception
915
-    * @return string
916
-    */
905
+    /**
906
+     * Converts the specified variable to JSON. Works just
907
+     * like the native `json_encode` method, except that it
908
+     * will trigger an exception on failure, which has the 
909
+     * json error details included in its developer details.
910
+     * 
911
+     * @param mixed $variable
912
+     * @param int $options JSON encode options.
913
+     * @param int $depth 
914
+     * @throws ConvertHelper_Exception
915
+     * @return string
916
+     */
917 917
     public static function var2json($variable, int $options=0, int $depth=512) : string
918 918
     {
919 919
         $result = json_encode($variable, $options, $depth);
@@ -934,12 +934,12 @@  discard block
 block discarded – undo
934 934
         );
935 935
     }
936 936
     
937
-   /**
938
-    * Strips all known UTF byte order marks from the specified string.
939
-    * 
940
-    * @param string $string
941
-    * @return string
942
-    */
937
+    /**
938
+     * Strips all known UTF byte order marks from the specified string.
939
+     * 
940
+     * @param string $string
941
+     * @return string
942
+     */
943 943
     public static function stripUTFBom($string)
944 944
     {
945 945
         $boms = FileHelper::getUTFBOMs();
@@ -954,13 +954,13 @@  discard block
 block discarded – undo
954 954
         return $string;
955 955
     }
956 956
 
957
-   /**
958
-    * Converts a string to valid utf8, regardless
959
-    * of the string's encoding(s).
960
-    * 
961
-    * @param string $string
962
-    * @return string
963
-    */
957
+    /**
958
+     * Converts a string to valid utf8, regardless
959
+     * of the string's encoding(s).
960
+     * 
961
+     * @param string $string
962
+     * @return string
963
+     */
964 964
     public static function string2utf8($string)
965 965
     {
966 966
         if(!self::isStringASCII($string)) {
@@ -970,15 +970,15 @@  discard block
 block discarded – undo
970 970
         return $string;
971 971
     }
972 972
     
973
-   /**
974
-    * Checks whether the specified string is an ASCII
975
-    * string, without any special or UTF8 characters.
976
-    * Note: empty strings and NULL are considered ASCII.
977
-    * Any variable types other than strings are not.
978
-    * 
979
-    * @param mixed $string
980
-    * @return boolean
981
-    */
973
+    /**
974
+     * Checks whether the specified string is an ASCII
975
+     * string, without any special or UTF8 characters.
976
+     * Note: empty strings and NULL are considered ASCII.
977
+     * Any variable types other than strings are not.
978
+     * 
979
+     * @param mixed $string
980
+     * @return boolean
981
+     */
982 982
     public static function isStringASCII($string) : bool
983 983
     {
984 984
         if($string === '' || $string === NULL) {
@@ -1003,22 +1003,22 @@  discard block
 block discarded – undo
1003 1003
         return $url;
1004 1004
     }
1005 1005
 
1006
-   /**
1007
-    * Calculates a percentage match of the source string with the target string.
1008
-    * 
1009
-    * Options are:
1010
-    * 
1011
-    * - maxLevenshtein, default: 10
1012
-    *   Any levenshtein results above this value are ignored.
1013
-    *   
1014
-    * - precision, default: 1
1015
-    *   The precision of the percentage float value
1016
-    * 
1017
-    * @param string $source
1018
-    * @param string $target
1019
-    * @param array $options
1020
-    * @return float
1021
-    */
1006
+    /**
1007
+     * Calculates a percentage match of the source string with the target string.
1008
+     * 
1009
+     * Options are:
1010
+     * 
1011
+     * - maxLevenshtein, default: 10
1012
+     *   Any levenshtein results above this value are ignored.
1013
+     *   
1014
+     * - precision, default: 1
1015
+     *   The precision of the percentage float value
1016
+     * 
1017
+     * @param string $source
1018
+     * @param string $target
1019
+     * @param array $options
1020
+     * @return float
1021
+     */
1022 1022
     public static function matchString($source, $target, $options=array())
1023 1023
     {
1024 1024
         $defaults = array(
@@ -1042,14 +1042,14 @@  discard block
 block discarded – undo
1042 1042
         return round(100 - $percent, $options['precision']);
1043 1043
     }
1044 1044
     
1045
-   /**
1046
-    * Converts a date interval to a human readable string with
1047
-    * all necessary time components, e.g. "1 year, 2 months and 4 days".
1048
-    * 
1049
-    * @param \DateInterval $interval
1050
-    * @return string
1051
-    * @see ConvertHelper_IntervalConverter
1052
-    */
1045
+    /**
1046
+     * Converts a date interval to a human readable string with
1047
+     * all necessary time components, e.g. "1 year, 2 months and 4 days".
1048
+     * 
1049
+     * @param \DateInterval $interval
1050
+     * @return string
1051
+     * @see ConvertHelper_IntervalConverter
1052
+     */
1053 1053
     public static function interval2string(\DateInterval $interval) : string
1054 1054
     {
1055 1055
         $converter = new ConvertHelper_IntervalConverter();
@@ -1064,60 +1064,60 @@  discard block
 block discarded – undo
1064 1064
     
1065 1065
     const INTERVAL_SECONDS = 'seconds';
1066 1066
     
1067
-   /**
1068
-    * Converts an interval to its total amount of days.
1069
-    * @param \DateInterval $interval
1070
-    * @return int
1071
-    */
1067
+    /**
1068
+     * Converts an interval to its total amount of days.
1069
+     * @param \DateInterval $interval
1070
+     * @return int
1071
+     */
1072 1072
     public static function interval2days(\DateInterval $interval) : int
1073 1073
     {
1074 1074
         return self::interval2total($interval, self::INTERVAL_DAYS);
1075 1075
     }
1076 1076
 
1077
-   /**
1078
-    * Converts an interval to its total amount of hours.
1079
-    * @param \DateInterval $interval
1080
-    * @return int
1081
-    */
1077
+    /**
1078
+     * Converts an interval to its total amount of hours.
1079
+     * @param \DateInterval $interval
1080
+     * @return int
1081
+     */
1082 1082
     public static function interval2hours(\DateInterval $interval) : int
1083 1083
     {
1084 1084
         return self::interval2total($interval, self::INTERVAL_HOURS);
1085 1085
     }
1086 1086
     
1087
-   /**
1088
-    * Converts an interval to its total amount of minutes. 
1089
-    * @param \DateInterval $interval
1090
-    * @return int
1091
-    */
1087
+    /**
1088
+     * Converts an interval to its total amount of minutes. 
1089
+     * @param \DateInterval $interval
1090
+     * @return int
1091
+     */
1092 1092
     public static function interval2minutes(\DateInterval $interval) : int
1093 1093
     {
1094 1094
         return self::interval2total($interval, self::INTERVAL_MINUTES);
1095 1095
     }
1096 1096
     
1097
-   /**
1098
-    * Converts an interval to its total amount of seconds.
1099
-    * @param \DateInterval $interval
1100
-    * @return int
1101
-    */    
1097
+    /**
1098
+     * Converts an interval to its total amount of seconds.
1099
+     * @param \DateInterval $interval
1100
+     * @return int
1101
+     */    
1102 1102
     public static function interval2seconds(\DateInterval $interval) : int
1103 1103
     {
1104 1104
         return self::interval2total($interval, self::INTERVAL_SECONDS);
1105 1105
     }
1106 1106
     
1107
-   /**
1108
-    * Calculates the total amount of days / hours / minutes or seconds
1109
-    * of a date interval object (depending in the specified units), and 
1110
-    * returns the total amount.
1111
-    * 
1112
-    * @param \DateInterval $interval
1113
-    * @param string $unit What total value to calculate.
1114
-    * @return integer
1115
-    * 
1116
-    * @see ConvertHelper::INTERVAL_SECONDS
1117
-    * @see ConvertHelper::INTERVAL_MINUTES
1118
-    * @see ConvertHelper::INTERVAL_HOURS
1119
-    * @see ConvertHelper::INTERVAL_DAYS
1120
-    */
1107
+    /**
1108
+     * Calculates the total amount of days / hours / minutes or seconds
1109
+     * of a date interval object (depending in the specified units), and 
1110
+     * returns the total amount.
1111
+     * 
1112
+     * @param \DateInterval $interval
1113
+     * @param string $unit What total value to calculate.
1114
+     * @return integer
1115
+     * 
1116
+     * @see ConvertHelper::INTERVAL_SECONDS
1117
+     * @see ConvertHelper::INTERVAL_MINUTES
1118
+     * @see ConvertHelper::INTERVAL_HOURS
1119
+     * @see ConvertHelper::INTERVAL_DAYS
1120
+     */
1121 1121
     public static function interval2total(\DateInterval $interval, $unit=self::INTERVAL_SECONDS) : int
1122 1122
     {
1123 1123
         $total = (int)$interval->format('%a');
@@ -1157,13 +1157,13 @@  discard block
 block discarded – undo
1157 1157
         'Sunday'
1158 1158
     );
1159 1159
     
1160
-   /**
1161
-    * Converts a date to the corresponding day name.
1162
-    * 
1163
-    * @param \DateTime $date
1164
-    * @param bool $short
1165
-    * @return string|NULL
1166
-    */
1160
+    /**
1161
+     * Converts a date to the corresponding day name.
1162
+     * 
1163
+     * @param \DateTime $date
1164
+     * @param bool $short
1165
+     * @return string|NULL
1166
+     */
1167 1167
     public static function date2dayName(\DateTime $date, bool $short=false)
1168 1168
     {
1169 1169
         $day = $date->format('l');
@@ -1178,21 +1178,21 @@  discard block
 block discarded – undo
1178 1178
         return null;
1179 1179
     }
1180 1180
     
1181
-   /**
1182
-    * Retrieves a list of english day names.
1183
-    * @return string[]
1184
-    */
1181
+    /**
1182
+     * Retrieves a list of english day names.
1183
+     * @return string[]
1184
+     */
1185 1185
     public static function getDayNamesInvariant()
1186 1186
     {
1187 1187
         return self::$daysInvariant;
1188 1188
     }
1189 1189
     
1190
-   /**
1191
-    * Retrieves the day names list for the current locale.
1192
-    * 
1193
-    * @param bool $short
1194
-    * @return array
1195
-    */
1190
+    /**
1191
+     * Retrieves the day names list for the current locale.
1192
+     * 
1193
+     * @param bool $short
1194
+     * @return array
1195
+     */
1196 1196
     public static function getDayNames(bool $short=false) : array
1197 1197
     {
1198 1198
         if($short) {
@@ -1252,16 +1252,16 @@  discard block
 block discarded – undo
1252 1252
         return $last;
1253 1253
     }
1254 1254
     
1255
-   /**
1256
-    * Splits a string into an array of all characters it is composed of.
1257
-    * Unicode character safe.
1258
-    * 
1259
-    * NOTE: Spaces and newlines (both \r and \n) are also considered single
1260
-    * characters.
1261
-    * 
1262
-    * @param string $string
1263
-    * @return array
1264
-    */
1255
+    /**
1256
+     * Splits a string into an array of all characters it is composed of.
1257
+     * Unicode character safe.
1258
+     * 
1259
+     * NOTE: Spaces and newlines (both \r and \n) are also considered single
1260
+     * characters.
1261
+     * 
1262
+     * @param string $string
1263
+     * @return array
1264
+     */
1265 1265
     public static function string2array(string $string) : array
1266 1266
     {
1267 1267
         $result = preg_split('//u', $string, null, PREG_SPLIT_NO_EMPTY);
@@ -1272,12 +1272,12 @@  discard block
 block discarded – undo
1272 1272
         return array();
1273 1273
     }
1274 1274
     
1275
-   /**
1276
-    * Checks whether the specified string contains HTML code.
1277
-    * 
1278
-    * @param string $string
1279
-    * @return boolean
1280
-    */
1275
+    /**
1276
+     * Checks whether the specified string contains HTML code.
1277
+     * 
1278
+     * @param string $string
1279
+     * @return boolean
1280
+     */
1281 1281
     public static function isStringHTML(string $string) : bool
1282 1282
     {
1283 1283
         if(preg_match('%<[a-z/][\s\S]*>%siU', $string)) {
@@ -1292,17 +1292,17 @@  discard block
 block discarded – undo
1292 1292
         return false;
1293 1293
     }
1294 1294
     
1295
-   /**
1296
-    * UTF8-safe wordwrap method: works like the regular wordwrap
1297
-    * PHP function but compatible with UTF8. Otherwise the lengths
1298
-    * are not calculated correctly.
1299
-    * 
1300
-    * @param string $str
1301
-    * @param int $width
1302
-    * @param string $break
1303
-    * @param bool $cut
1304
-    * @return string
1305
-    */
1295
+    /**
1296
+     * UTF8-safe wordwrap method: works like the regular wordwrap
1297
+     * PHP function but compatible with UTF8. Otherwise the lengths
1298
+     * are not calculated correctly.
1299
+     * 
1300
+     * @param string $str
1301
+     * @param int $width
1302
+     * @param string $break
1303
+     * @param bool $cut
1304
+     * @return string
1305
+     */
1306 1306
     public static function wordwrap(string $str, int $width = 75, string $break = "\n", bool $cut = false) : string 
1307 1307
     {
1308 1308
         $wrapper = new ConvertHelper_WordWrapper();
@@ -1314,27 +1314,27 @@  discard block
 block discarded – undo
1314 1314
         ->wrapText($str);
1315 1315
     }
1316 1316
     
1317
-   /**
1318
-    * Calculates the byte length of a string, taking into 
1319
-    * account any unicode characters.
1320
-    * 
1321
-    * @param string $string
1322
-    * @return int
1323
-    * @see https://stackoverflow.com/a/9718273/2298192
1324
-    */
1317
+    /**
1318
+     * Calculates the byte length of a string, taking into 
1319
+     * account any unicode characters.
1320
+     * 
1321
+     * @param string $string
1322
+     * @return int
1323
+     * @see https://stackoverflow.com/a/9718273/2298192
1324
+     */
1325 1325
     public static function string2bytes($string)
1326 1326
     {
1327 1327
         return mb_strlen($string, '8bit');
1328 1328
     }
1329 1329
     
1330
-   /**
1331
-    * Creates a short, 8-character long hash for the specified string.
1332
-    * 
1333
-    * WARNING: Not cryptographically safe.
1334
-    * 
1335
-    * @param string $string
1336
-    * @return string
1337
-    */
1330
+    /**
1331
+     * Creates a short, 8-character long hash for the specified string.
1332
+     * 
1333
+     * WARNING: Not cryptographically safe.
1334
+     * 
1335
+     * @param string $string
1336
+     * @return string
1337
+     */
1338 1338
     public static function string2shortHash($string)
1339 1339
     {
1340 1340
         return hash('crc32', $string, false);
@@ -1360,40 +1360,40 @@  discard block
 block discarded – undo
1360 1360
         return ConvertHelper_ThrowableInfo::fromThrowable($e);
1361 1361
     }
1362 1362
     
1363
-   /**
1364
-    * Parses the specified query string like the native 
1365
-    * function <code>parse_str</code>, without the key
1366
-    * naming limitations.
1367
-    * 
1368
-    * Using parse_str, dots or spaces in key names are 
1369
-    * replaced by underscores. This method keeps all names
1370
-    * intact.
1371
-    * 
1372
-    * It still uses the parse_str implementation as it 
1373
-    * is tested and tried, but fixes the parameter names
1374
-    * after parsing, as needed.
1375
-    * 
1376
-    * @param string $queryString
1377
-    * @return array
1378
-    * @see ConvertHelper_QueryParser
1379
-    */
1363
+    /**
1364
+     * Parses the specified query string like the native 
1365
+     * function <code>parse_str</code>, without the key
1366
+     * naming limitations.
1367
+     * 
1368
+     * Using parse_str, dots or spaces in key names are 
1369
+     * replaced by underscores. This method keeps all names
1370
+     * intact.
1371
+     * 
1372
+     * It still uses the parse_str implementation as it 
1373
+     * is tested and tried, but fixes the parameter names
1374
+     * after parsing, as needed.
1375
+     * 
1376
+     * @param string $queryString
1377
+     * @return array
1378
+     * @see ConvertHelper_QueryParser
1379
+     */
1380 1380
     public static function parseQueryString(string $queryString) : array
1381 1381
     {
1382 1382
         $parser = new ConvertHelper_QueryParser();
1383 1383
         return $parser->parse($queryString);
1384 1384
     }
1385 1385
 
1386
-   /**
1387
-    * Searches for needle in the specified string, and returns a list
1388
-    * of all occurrences, including the matched string. The matched 
1389
-    * string is useful when doing a case insensitive search, as it 
1390
-    * shows the exact matched case of needle.
1391
-    *   
1392
-    * @param string $needle
1393
-    * @param string $haystack
1394
-    * @param bool $caseInsensitive
1395
-    * @return ConvertHelper_StringMatch[]
1396
-    */
1386
+    /**
1387
+     * Searches for needle in the specified string, and returns a list
1388
+     * of all occurrences, including the matched string. The matched 
1389
+     * string is useful when doing a case insensitive search, as it 
1390
+     * shows the exact matched case of needle.
1391
+     *   
1392
+     * @param string $needle
1393
+     * @param string $haystack
1394
+     * @param bool $caseInsensitive
1395
+     * @return ConvertHelper_StringMatch[]
1396
+     */
1397 1397
     public static function findString(string $needle, string $haystack, bool $caseInsensitive=false)
1398 1398
     {
1399 1399
         if($needle === '') {
@@ -1419,14 +1419,14 @@  discard block
 block discarded – undo
1419 1419
         return $positions;
1420 1420
     }
1421 1421
     
1422
-   /**
1423
-    * Like explode, but trims all entries, and removes 
1424
-    * empty entries from the resulting array.
1425
-    * 
1426
-    * @param string $delimiter
1427
-    * @param string $string
1428
-    * @return string[]
1429
-    */
1422
+    /**
1423
+     * Like explode, but trims all entries, and removes 
1424
+     * empty entries from the resulting array.
1425
+     * 
1426
+     * @param string $delimiter
1427
+     * @param string $string
1428
+     * @return string[]
1429
+     */
1430 1430
     public static function explodeTrim(string $delimiter, string $string) : array
1431 1431
     {
1432 1432
         if(empty($string) || empty($delimiter)) {
@@ -1448,12 +1448,12 @@  discard block
 block discarded – undo
1448 1448
     
1449 1449
     protected static $eolChars;
1450 1450
 
1451
-   /**
1452
-    * Detects the most used end-of-line character in the subject string.
1453
-    * 
1454
-    * @param string $subjectString The string to check.
1455
-    * @return NULL|ConvertHelper_EOL The detected EOL instance, or NULL if none has been detected.
1456
-    */
1451
+    /**
1452
+     * Detects the most used end-of-line character in the subject string.
1453
+     * 
1454
+     * @param string $subjectString The string to check.
1455
+     * @return NULL|ConvertHelper_EOL The detected EOL instance, or NULL if none has been detected.
1456
+     */
1457 1457
     public static function detectEOLCharacter(string $subjectString) : ?ConvertHelper_EOL
1458 1458
     {
1459 1459
         if(empty($subjectString)) {
@@ -1465,27 +1465,27 @@  discard block
 block discarded – undo
1465 1465
             $cr = chr((int)hexdec('0d'));
1466 1466
             $lf = chr((int)hexdec('0a'));
1467 1467
             
1468
-           self::$eolChars = array(
1469
-               array(
1470
-                   'char' => $cr.$lf,
1471
-                   'type' => ConvertHelper_EOL::TYPE_CRLF,
1472
-                   'description' => t('Carriage return followed by a line feed'),
1473
-               ),
1474
-               array(
1475
-                   'char' => $lf.$cr,
1476
-                   'type' => ConvertHelper_EOL::TYPE_LFCR,
1477
-                   'description' => t('Line feed followed by a carriage return'),
1478
-               ),
1479
-               array(
1480
-                  'char' => $lf,
1481
-                  'type' => ConvertHelper_EOL::TYPE_LF,
1482
-                  'description' => t('Line feed'),
1483
-               ),
1484
-               array(
1485
-                  'char' => $cr,
1486
-                  'type' => ConvertHelper_EOL::TYPE_CR,
1487
-                  'description' => t('Carriage Return'),
1488
-               ),
1468
+            self::$eolChars = array(
1469
+                array(
1470
+                    'char' => $cr.$lf,
1471
+                    'type' => ConvertHelper_EOL::TYPE_CRLF,
1472
+                    'description' => t('Carriage return followed by a line feed'),
1473
+                ),
1474
+                array(
1475
+                    'char' => $lf.$cr,
1476
+                    'type' => ConvertHelper_EOL::TYPE_LFCR,
1477
+                    'description' => t('Line feed followed by a carriage return'),
1478
+                ),
1479
+                array(
1480
+                    'char' => $lf,
1481
+                    'type' => ConvertHelper_EOL::TYPE_LF,
1482
+                    'description' => t('Line feed'),
1483
+                ),
1484
+                array(
1485
+                    'char' => $cr,
1486
+                    'type' => ConvertHelper_EOL::TYPE_CR,
1487
+                    'description' => t('Carriage Return'),
1488
+                ),
1489 1489
             );
1490 1490
         }
1491 1491
         
@@ -1513,13 +1513,13 @@  discard block
 block discarded – undo
1513 1513
         );
1514 1514
     }
1515 1515
 
1516
-   /**
1517
-    * Removes the specified keys from the target array,
1518
-    * if they exist.
1519
-    * 
1520
-    * @param array $array
1521
-    * @param array $keys
1522
-    */
1516
+    /**
1517
+     * Removes the specified keys from the target array,
1518
+     * if they exist.
1519
+     * 
1520
+     * @param array $array
1521
+     * @param array $keys
1522
+     */
1523 1523
     public static function arrayRemoveKeys(array &$array, array $keys) : void
1524 1524
     {
1525 1525
         foreach($keys as $key) 
@@ -1530,13 +1530,13 @@  discard block
 block discarded – undo
1530 1530
         }
1531 1531
     }
1532 1532
     
1533
-   /**
1534
-    * Checks if the specified variable is an integer or a string containing an integer.
1535
-    * Accepts both positive and negative integers.
1536
-    * 
1537
-    * @param mixed $value
1538
-    * @return bool
1539
-    */
1533
+    /**
1534
+     * Checks if the specified variable is an integer or a string containing an integer.
1535
+     * Accepts both positive and negative integers.
1536
+     * 
1537
+     * @param mixed $value
1538
+     * @return bool
1539
+     */
1540 1540
     public static function isInteger($value) : bool
1541 1541
     {
1542 1542
         if(is_int($value)) {
@@ -1556,40 +1556,40 @@  discard block
 block discarded – undo
1556 1556
         return false;    
1557 1557
     }
1558 1558
     
1559
-   /**
1560
-    * Converts an amount of seconds to a DateInterval object.
1561
-    * 
1562
-    * @param int $seconds
1563
-    * @return \DateInterval
1564
-    * @throws ConvertHelper_Exception If the date interval cannot be created.
1565
-    * 
1566
-    * @see ConvertHelper::ERROR_CANNOT_GET_DATE_DIFF
1567
-    */
1559
+    /**
1560
+     * Converts an amount of seconds to a DateInterval object.
1561
+     * 
1562
+     * @param int $seconds
1563
+     * @return \DateInterval
1564
+     * @throws ConvertHelper_Exception If the date interval cannot be created.
1565
+     * 
1566
+     * @see ConvertHelper::ERROR_CANNOT_GET_DATE_DIFF
1567
+     */
1568 1568
     public static function seconds2interval(int $seconds) : \DateInterval
1569 1569
     {
1570 1570
         return ConvertHelper_DateInterval::fromSeconds($seconds)->getInterval();
1571 1571
     }
1572 1572
     
1573
-   /**
1574
-    * Converts a size string like "50 MB" to the corresponding byte size.
1575
-    * It is case insensitive, ignores spaces, and supports both traditional
1576
-    * "MB" and "MiB" notations.
1577
-    * 
1578
-    * @param string $size
1579
-    * @return int
1580
-    */
1573
+    /**
1574
+     * Converts a size string like "50 MB" to the corresponding byte size.
1575
+     * It is case insensitive, ignores spaces, and supports both traditional
1576
+     * "MB" and "MiB" notations.
1577
+     * 
1578
+     * @param string $size
1579
+     * @return int
1580
+     */
1581 1581
     public static function size2bytes(string $size) : int
1582 1582
     {
1583 1583
         return self::parseSize($size)->toBytes();
1584 1584
     }
1585 1585
     
1586
-   /**
1587
-    * Parses a size string like "50 MB" and returns a size notation instance
1588
-    * that has utility methods to access information on it, and convert it.
1589
-    * 
1590
-    * @param string $size
1591
-    * @return ConvertHelper_SizeNotation
1592
-    */
1586
+    /**
1587
+     * Parses a size string like "50 MB" and returns a size notation instance
1588
+     * that has utility methods to access information on it, and convert it.
1589
+     * 
1590
+     * @param string $size
1591
+     * @return ConvertHelper_SizeNotation
1592
+     */
1593 1593
     public static function parseSize(string $size) : ConvertHelper_SizeNotation
1594 1594
     {
1595 1595
         return new ConvertHelper_SizeNotation($size);
Please login to merge, or discard this patch.
Spacing   +93 added lines, -93 removed lines patch added patch discarded remove patch
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
             $amount = substr_count($line, "\t") - $min;
60 60
             $line = trim($line);
61 61
             if ($amount >= 1) {
62
-                $line = str_repeat("\t", $amount) . $line;
62
+                $line = str_repeat("\t", $amount).$line;
63 63
             }
64 64
 
65 65
             $converted[] = $line;
@@ -131,10 +131,10 @@  discard block
 block discarded – undo
131 131
 
132 132
         // specifically handle zero
133 133
         if ($seconds <= 0) {
134
-            return '0 ' . t('seconds');
134
+            return '0 '.t('seconds');
135 135
         }
136 136
         
137
-        if($seconds < 1) {
137
+        if ($seconds < 1) {
138 138
             return t('less than a second');
139 139
         }
140 140
 
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
         foreach ($units as $def) {
143 143
             $quot = intval($seconds / $def['value']);
144 144
             if ($quot) {
145
-                $item = $quot . ' ';
145
+                $item = $quot.' ';
146 146
                 if (abs($quot) > 1) {
147 147
                     $item .= $def['plural'];
148 148
                 } else {
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
             return $last;
160 160
         }
161 161
 
162
-        return implode(', ', $tokens) . ' ' . t('and') . ' ' . $last;
162
+        return implode(', ', $tokens).' '.t('and').' '.$last;
163 163
     }
164 164
 
165 165
    /**
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
     {
179 179
          $converter = new ConvertHelper_DurationConverter();
180 180
          
181
-         if($datefrom instanceof \DateTime)
181
+         if ($datefrom instanceof \DateTime)
182 182
          {
183 183
              $converter->setDateFrom($datefrom);
184 184
          }
@@ -187,11 +187,11 @@  discard block
 block discarded – undo
187 187
              $converter->setDateFrom(self::timestamp2date($datefrom)); 
188 188
          }
189 189
 
190
-         if($dateto instanceof \DateTime)
190
+         if ($dateto instanceof \DateTime)
191 191
          {
192 192
              $converter->setDateTo($dateto);
193 193
          }
194
-         else if($dateto > 0)
194
+         else if ($dateto > 0)
195 195
          {
196 196
              $converter->setDateTo(self::timestamp2date($dateto));
197 197
          }
@@ -211,9 +211,9 @@  discard block
 block discarded – undo
211 211
         return $geshi->parse_code();
212 212
     }
213 213
     
214
-    public static function highlight_xml($xml, $formatSource=false)
214
+    public static function highlight_xml($xml, $formatSource = false)
215 215
     {
216
-        if($formatSource) 
216
+        if ($formatSource) 
217 217
         {
218 218
             $dom = new \DOMDocument();
219 219
             $dom->loadXML($xml);
@@ -280,16 +280,16 @@  discard block
 block discarded – undo
280 280
             return $text;
281 281
         }
282 282
 
283
-        $text = trim(mb_substr($text, 0, $targetLength)) . $append;
283
+        $text = trim(mb_substr($text, 0, $targetLength)).$append;
284 284
 
285 285
         return $text;
286 286
     }
287 287
 
288
-    public static function var_dump($var, $html=true) : string
288
+    public static function var_dump($var, $html = true) : string
289 289
     {
290 290
         $info = parseVariable($var);
291 291
         
292
-        if($html) {
292
+        if ($html) {
293 293
             return $info->toHTML();
294 294
         }
295 295
         
@@ -304,11 +304,11 @@  discard block
 block discarded – undo
304 304
     * @param bool $html Whether to style the dump as HTML.
305 305
     * @return string
306 306
     */
307
-    public static function print_r($var, bool $return=false, bool $html=true) : string
307
+    public static function print_r($var, bool $return = false, bool $html = true) : string
308 308
     {
309 309
         $result = parseVariable($var)->enableType()->toString();
310 310
         
311
-        if($html) 
311
+        if ($html) 
312 312
         {
313 313
             $result = 
314 314
             '<pre style="background:#fff;color:#333;padding:16px;border:solid 1px #bbb;border-radius:4px">'.
@@ -316,7 +316,7 @@  discard block
 block discarded – undo
316 316
             '</pre>';
317 317
         }
318 318
         
319
-        if(!$return) 
319
+        if (!$return) 
320 320
         {
321 321
             echo $result;
322 322
         }
@@ -344,17 +344,17 @@  discard block
 block discarded – undo
344 344
     */
345 345
     public static function string2bool($string) : bool
346 346
     {
347
-        if($string === '' || $string === null || !is_scalar($string)) 
347
+        if ($string === '' || $string === null || !is_scalar($string)) 
348 348
         {
349 349
             return false;
350 350
         }
351 351
         
352
-        if(is_bool($string)) 
352
+        if (is_bool($string)) 
353 353
         {
354 354
             return $string;
355 355
         }
356 356
 
357
-        if(array_key_exists($string, self::$booleanStrings)) 
357
+        if (array_key_exists($string, self::$booleanStrings)) 
358 358
         {
359 359
             return self::$booleanStrings[$string];
360 360
         }
@@ -409,10 +409,10 @@  discard block
 block discarded – undo
409 409
     public static function date2listLabel(\DateTime $date, $includeTime = false, $shortMonth = false)
410 410
     {
411 411
         $today = new \DateTime();
412
-        if($date->format('d.m.Y') == $today->format('d.m.Y')) {
412
+        if ($date->format('d.m.Y') == $today->format('d.m.Y')) {
413 413
             $label = t('Today');
414 414
         } else {
415
-            $label = $date->format('d') . '. ' . self::month2string((int)$date->format('m'), $shortMonth) . ' ';
415
+            $label = $date->format('d').'. '.self::month2string((int)$date->format('m'), $shortMonth).' ';
416 416
             if ($date->format('Y') != date('Y')) {
417 417
                 $label .= $date->format('Y');
418 418
             }
@@ -503,28 +503,28 @@  discard block
 block discarded – undo
503 503
         $hexAlphabet = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F');
504 504
         
505 505
         $stack = array();
506
-        foreach(self::$controlChars as $char)
506
+        foreach (self::$controlChars as $char)
507 507
         {
508 508
             $tokens = explode('-', $char);
509 509
             $start = $tokens[0];
510 510
             $end = $tokens[1];
511 511
             $prefix = substr($start, 0, 3);
512 512
             $range = array();
513
-            foreach($hexAlphabet as $number) {
513
+            foreach ($hexAlphabet as $number) {
514 514
                 $range[] = $prefix.$number;
515 515
             }
516 516
             
517 517
             $use = false;
518
-            foreach($range as $number) {
519
-                if($number == $start) {
518
+            foreach ($range as $number) {
519
+                if ($number == $start) {
520 520
                     $use = true;
521 521
                 }
522 522
                 
523
-                if($use) {
523
+                if ($use) {
524 524
                     $stack[] = $number;
525 525
                 }
526 526
                 
527
-                if($number == $end) {
527
+                if ($number == $end) {
528 528
                     break;
529 529
                 }
530 530
             }
@@ -545,7 +545,7 @@  discard block
 block discarded – undo
545 545
         $chars = self::getControlCharactersAsHex();
546 546
         
547 547
         $result = array();
548
-        foreach($chars as $char) {
548
+        foreach ($chars as $char) {
549 549
             $result[] = hex2bin($char);
550 550
         }
551 551
         
@@ -563,14 +563,14 @@  discard block
 block discarded – undo
563 563
         $chars = self::getControlCharactersAsHex();
564 564
         
565 565
         $result = array();
566
-        foreach($chars as $char) {
566
+        foreach ($chars as $char) {
567 567
             $result[] = '\u'.strtolower($char);
568 568
         }
569 569
         
570 570
         return $result;
571 571
     }
572 572
     
573
-    protected static $controlChars =  array(
573
+    protected static $controlChars = array(
574 574
         '0000-0008', // control chars
575 575
         '000E-000F', // control chars
576 576
         '0010-001F', // control chars
@@ -592,19 +592,19 @@  discard block
 block discarded – undo
592 592
      */
593 593
     public static function stripControlCharacters(string $string) : string
594 594
     {
595
-        if(empty($string)) {
595
+        if (empty($string)) {
596 596
             return $string;
597 597
         }
598 598
         
599 599
         // create the regex from the unicode characters list
600
-        if(!isset(self::$controlCharsRegex)) 
600
+        if (!isset(self::$controlCharsRegex)) 
601 601
         {
602 602
             $chars = self::getControlCharactersAsHex();
603 603
 
604 604
             // we use the notation \x{0000} to specify the unicode character key
605 605
             // in the regular expression.
606 606
             $stack = array();
607
-            foreach($chars as $char) {
607
+            foreach ($chars as $char) {
608 608
                 $stack[] = '\x{'.$char.'}';
609 609
             }
610 610
             
@@ -635,12 +635,12 @@  discard block
 block discarded – undo
635 635
         $output = '';
636 636
         $split = str_split($unicodeChar);
637 637
         
638
-        foreach($split as $octet) 
638
+        foreach ($split as $octet) 
639 639
         {
640 640
             $ordInt = ord($octet);
641 641
             // Convert from int (base 10) to hex (base 16), for PHP \x syntax
642 642
             $ordHex = base_convert((string)$ordInt, 10, 16);
643
-            $output .= '\x' . $ordHex;
643
+            $output .= '\x'.$ordHex;
644 644
         }
645 645
         
646 646
         return $output;
@@ -673,19 +673,19 @@  discard block
 block discarded – undo
673 673
     
674 674
     protected static function convertScalarForComparison($scalar)
675 675
     {
676
-        if($scalar === '' || is_null($scalar)) {
676
+        if ($scalar === '' || is_null($scalar)) {
677 677
             return null;
678 678
         }
679 679
         
680
-        if(is_bool($scalar)) {
680
+        if (is_bool($scalar)) {
681 681
             return self::bool2string($scalar);
682 682
         }
683 683
         
684
-        if(is_array($scalar)) {
684
+        if (is_array($scalar)) {
685 685
             $scalar = md5(serialize($scalar));
686 686
         }
687 687
         
688
-        if($scalar !== null && !is_scalar($scalar)) {
688
+        if ($scalar !== null && !is_scalar($scalar)) {
689 689
             throw new ConvertHelper_Exception(
690 690
                 'Not a scalar value in comparison',
691 691
                 null,
@@ -734,7 +734,7 @@  discard block
 block discarded – undo
734 734
     public static function bool2string($boolean, bool $yesno = false) : string
735 735
     {
736 736
         // allow 'yes', 'true', 'no', 'false' string notations as well
737
-        if(!is_bool($boolean)) {
737
+        if (!is_bool($boolean)) {
738 738
             $boolean = self::string2bool($boolean);
739 739
         }
740 740
         
@@ -775,15 +775,15 @@  discard block
 block discarded – undo
775 775
     public static function array2attributeString($array)
776 776
     {
777 777
         $tokens = array();
778
-        foreach($array as $attr => $value) {
779
-            if($value == '' || $value == null) {
778
+        foreach ($array as $attr => $value) {
779
+            if ($value == '' || $value == null) {
780 780
                 continue;
781 781
             }
782 782
             
783 783
             $tokens[] = $attr.'="'.$value.'"';
784 784
         }
785 785
         
786
-        if(empty($tokens)) {
786
+        if (empty($tokens)) {
787 787
             return '';
788 788
         }
789 789
         
@@ -798,10 +798,10 @@  discard block
 block discarded – undo
798 798
     * @param string $string
799 799
     * @return string
800 800
     */
801
-    public static function string2attributeJS($string, $quoted=true)
801
+    public static function string2attributeJS($string, $quoted = true)
802 802
     {
803 803
         $converted = addslashes(htmlspecialchars(strip_tags($string), ENT_QUOTES, 'UTF-8'));
804
-        if($quoted) {
804
+        if ($quoted) {
805 805
             $converted = "'".$converted."'";
806 806
         } 
807 807
         
@@ -819,11 +819,11 @@  discard block
 block discarded – undo
819 819
     */
820 820
     public static function isBoolean($value) : bool
821 821
     {
822
-        if(is_bool($value)) {
822
+        if (is_bool($value)) {
823 823
             return true;
824 824
         }
825 825
         
826
-        if(!is_scalar($value)) {
826
+        if (!is_scalar($value)) {
827 827
             return false;
828 828
         }
829 829
         
@@ -839,7 +839,7 @@  discard block
 block discarded – undo
839 839
     public static function array2styleString(array $subject) : string
840 840
     {
841 841
         $tokens = array();
842
-        foreach($subject as $name => $value) {
842
+        foreach ($subject as $name => $value) {
843 843
             $tokens[] = $name.':'.$value;
844 844
         }
845 845
         
@@ -897,7 +897,7 @@  discard block
 block discarded – undo
897 897
     * 
898 898
     * @see JSHelper::buildRegexStatement()
899 899
     */
900
-    public static function regex2js(string $regex, string $statementType=JSHelper::JS_REGEX_OBJECT)
900
+    public static function regex2js(string $regex, string $statementType = JSHelper::JS_REGEX_OBJECT)
901 901
     {
902 902
         return JSHelper::buildRegexStatement($regex, $statementType);
903 903
     }
@@ -914,11 +914,11 @@  discard block
 block discarded – undo
914 914
     * @throws ConvertHelper_Exception
915 915
     * @return string
916 916
     */
917
-    public static function var2json($variable, int $options=0, int $depth=512) : string
917
+    public static function var2json($variable, int $options = 0, int $depth = 512) : string
918 918
     {
919 919
         $result = json_encode($variable, $options, $depth);
920 920
         
921
-        if($result !== false) {
921
+        if ($result !== false) {
922 922
             return $result;
923 923
         }
924 924
         
@@ -943,10 +943,10 @@  discard block
 block discarded – undo
943 943
     public static function stripUTFBom($string)
944 944
     {
945 945
         $boms = FileHelper::getUTFBOMs();
946
-        foreach($boms as $bomChars) {
946
+        foreach ($boms as $bomChars) {
947 947
             $length = mb_strlen($bomChars);
948 948
             $text = mb_substr($string, 0, $length);
949
-            if($text==$bomChars) {
949
+            if ($text == $bomChars) {
950 950
                 return mb_substr($string, $length);
951 951
             }
952 952
         }
@@ -963,7 +963,7 @@  discard block
 block discarded – undo
963 963
     */
964 964
     public static function string2utf8($string)
965 965
     {
966
-        if(!self::isStringASCII($string)) {
966
+        if (!self::isStringASCII($string)) {
967 967
             return \ForceUTF8\Encoding::toUTF8($string);
968 968
         }
969 969
         
@@ -981,11 +981,11 @@  discard block
 block discarded – undo
981 981
     */
982 982
     public static function isStringASCII($string) : bool
983 983
     {
984
-        if($string === '' || $string === NULL) {
984
+        if ($string === '' || $string === NULL) {
985 985
             return true;
986 986
         }
987 987
         
988
-        if(!is_string($string)) {
988
+        if (!is_string($string)) {
989 989
             return false;
990 990
         }
991 991
         
@@ -1019,7 +1019,7 @@  discard block
 block discarded – undo
1019 1019
     * @param array $options
1020 1020
     * @return float
1021 1021
     */
1022
-    public static function matchString($source, $target, $options=array())
1022
+    public static function matchString($source, $target, $options = array())
1023 1023
     {
1024 1024
         $defaults = array(
1025 1025
             'maxLevenshtein' => 10,
@@ -1029,12 +1029,12 @@  discard block
 block discarded – undo
1029 1029
         $options = array_merge($defaults, $options);
1030 1030
         
1031 1031
         // avoid doing this via levenshtein
1032
-        if($source == $target) {
1032
+        if ($source == $target) {
1033 1033
             return 100;
1034 1034
         }
1035 1035
         
1036 1036
         $diff = levenshtein($source, $target);
1037
-        if($diff > $options['maxLevenshtein']) {
1037
+        if ($diff > $options['maxLevenshtein']) {
1038 1038
             return 0;
1039 1039
         }
1040 1040
         
@@ -1118,24 +1118,24 @@  discard block
 block discarded – undo
1118 1118
     * @see ConvertHelper::INTERVAL_HOURS
1119 1119
     * @see ConvertHelper::INTERVAL_DAYS
1120 1120
     */
1121
-    public static function interval2total(\DateInterval $interval, $unit=self::INTERVAL_SECONDS) : int
1121
+    public static function interval2total(\DateInterval $interval, $unit = self::INTERVAL_SECONDS) : int
1122 1122
     {
1123 1123
         $total = (int)$interval->format('%a');
1124 1124
         if ($unit == self::INTERVAL_DAYS) {
1125 1125
             return $total;
1126 1126
         }
1127 1127
         
1128
-        $total = ($total * 24) + ((int)$interval->h );
1128
+        $total = ($total * 24) + ((int)$interval->h);
1129 1129
         if ($unit == self::INTERVAL_HOURS) {
1130 1130
             return $total;
1131 1131
         }
1132 1132
     
1133
-        $total = ($total * 60) + ((int)$interval->i );
1133
+        $total = ($total * 60) + ((int)$interval->i);
1134 1134
         if ($unit == self::INTERVAL_MINUTES) {
1135 1135
             return $total;
1136 1136
         }
1137 1137
 
1138
-        $total = ($total * 60) + ((int)$interval->s );
1138
+        $total = ($total * 60) + ((int)$interval->s);
1139 1139
         if ($unit == self::INTERVAL_SECONDS) {
1140 1140
             return $total;
1141 1141
         }
@@ -1164,13 +1164,13 @@  discard block
 block discarded – undo
1164 1164
     * @param bool $short
1165 1165
     * @return string|NULL
1166 1166
     */
1167
-    public static function date2dayName(\DateTime $date, bool $short=false)
1167
+    public static function date2dayName(\DateTime $date, bool $short = false)
1168 1168
     {
1169 1169
         $day = $date->format('l');
1170 1170
         $invariant = self::getDayNamesInvariant();
1171 1171
         
1172 1172
         $idx = array_search($day, $invariant);
1173
-        if($idx !== false) {
1173
+        if ($idx !== false) {
1174 1174
             $localized = self::getDayNames($short);
1175 1175
             return $localized[$idx];
1176 1176
         }
@@ -1193,10 +1193,10 @@  discard block
 block discarded – undo
1193 1193
     * @param bool $short
1194 1194
     * @return array
1195 1195
     */
1196
-    public static function getDayNames(bool $short=false) : array
1196
+    public static function getDayNames(bool $short = false) : array
1197 1197
     {
1198
-        if($short) {
1199
-            if(!isset(self::$daysShort)) {
1198
+        if ($short) {
1199
+            if (!isset(self::$daysShort)) {
1200 1200
                 self::$daysShort = array(
1201 1201
                     t('Mon'),
1202 1202
                     t('Tue'),
@@ -1211,7 +1211,7 @@  discard block
 block discarded – undo
1211 1211
             return self::$daysShort;
1212 1212
         }
1213 1213
         
1214
-        if(!isset(self::$days)) {
1214
+        if (!isset(self::$days)) {
1215 1215
             self::$days = array(
1216 1216
                 t('Monday'),
1217 1217
                 t('Tuesday'),
@@ -1236,17 +1236,17 @@  discard block
 block discarded – undo
1236 1236
      */
1237 1237
     public static function implodeWithAnd(array $list, $sep = ', ', $conjunction = null)
1238 1238
     {
1239
-        if(empty($list)) {
1239
+        if (empty($list)) {
1240 1240
             return '';
1241 1241
         }
1242 1242
         
1243
-        if(empty($conjunction)) {
1243
+        if (empty($conjunction)) {
1244 1244
             $conjunction = t('and');
1245 1245
         }
1246 1246
         
1247 1247
         $last = array_pop($list);
1248
-        if($list) {
1249
-            return implode($sep, $list) . $conjunction . ' ' . $last;
1248
+        if ($list) {
1249
+            return implode($sep, $list).$conjunction.' '.$last;
1250 1250
         }
1251 1251
         
1252 1252
         return $last;
@@ -1265,7 +1265,7 @@  discard block
 block discarded – undo
1265 1265
     public static function string2array(string $string) : array
1266 1266
     {
1267 1267
         $result = preg_split('//u', $string, null, PREG_SPLIT_NO_EMPTY);
1268
-        if($result !== false) {
1268
+        if ($result !== false) {
1269 1269
             return $result;
1270 1270
         }
1271 1271
         
@@ -1280,12 +1280,12 @@  discard block
 block discarded – undo
1280 1280
     */
1281 1281
     public static function isStringHTML(string $string) : bool
1282 1282
     {
1283
-        if(preg_match('%<[a-z/][\s\S]*>%siU', $string)) {
1283
+        if (preg_match('%<[a-z/][\s\S]*>%siU', $string)) {
1284 1284
             return true;
1285 1285
         }
1286 1286
         
1287 1287
         $decoded = html_entity_decode($string);
1288
-        if($decoded !== $string) {
1288
+        if ($decoded !== $string) {
1289 1289
             return true;
1290 1290
         }
1291 1291
         
@@ -1394,14 +1394,14 @@  discard block
 block discarded – undo
1394 1394
     * @param bool $caseInsensitive
1395 1395
     * @return ConvertHelper_StringMatch[]
1396 1396
     */
1397
-    public static function findString(string $needle, string $haystack, bool $caseInsensitive=false)
1397
+    public static function findString(string $needle, string $haystack, bool $caseInsensitive = false)
1398 1398
     {
1399
-        if($needle === '') {
1399
+        if ($needle === '') {
1400 1400
             return array();
1401 1401
         }
1402 1402
         
1403 1403
         $function = 'mb_strpos';
1404
-        if($caseInsensitive) {
1404
+        if ($caseInsensitive) {
1405 1405
             $function = 'mb_stripos';
1406 1406
         }
1407 1407
         
@@ -1409,7 +1409,7 @@  discard block
 block discarded – undo
1409 1409
         $positions = array();
1410 1410
         $length = mb_strlen($needle);
1411 1411
         
1412
-        while( ($pos = $function($haystack, $needle, $pos)) !== false) 
1412
+        while (($pos = $function($haystack, $needle, $pos)) !== false) 
1413 1413
         {
1414 1414
             $match = mb_substr($haystack, $pos, $length);
1415 1415
             $positions[] = new ConvertHelper_StringMatch($pos, $match);
@@ -1429,7 +1429,7 @@  discard block
 block discarded – undo
1429 1429
     */
1430 1430
     public static function explodeTrim(string $delimiter, string $string) : array
1431 1431
     {
1432
-        if(empty($string) || empty($delimiter)) {
1432
+        if (empty($string) || empty($delimiter)) {
1433 1433
             return array();
1434 1434
         }
1435 1435
         
@@ -1437,8 +1437,8 @@  discard block
 block discarded – undo
1437 1437
         $tokens = array_map('trim', $tokens);
1438 1438
         
1439 1439
         $keep = array();
1440
-        foreach($tokens as $token) {
1441
-            if($token !== '') {
1440
+        foreach ($tokens as $token) {
1441
+            if ($token !== '') {
1442 1442
                 $keep[] = $token;
1443 1443
             }
1444 1444
         }
@@ -1456,11 +1456,11 @@  discard block
 block discarded – undo
1456 1456
     */
1457 1457
     public static function detectEOLCharacter(string $subjectString) : ?ConvertHelper_EOL
1458 1458
     {
1459
-        if(empty($subjectString)) {
1459
+        if (empty($subjectString)) {
1460 1460
             return null;
1461 1461
         }
1462 1462
         
1463
-        if(!isset(self::$eolChars))
1463
+        if (!isset(self::$eolChars))
1464 1464
         {
1465 1465
             $cr = chr((int)hexdec('0d'));
1466 1466
             $lf = chr((int)hexdec('0a'));
@@ -1491,18 +1491,18 @@  discard block
 block discarded – undo
1491 1491
         
1492 1492
         $max = 0;
1493 1493
         $results = array();
1494
-        foreach(self::$eolChars as $def) 
1494
+        foreach (self::$eolChars as $def) 
1495 1495
         {
1496 1496
             $amount = substr_count($subjectString, $def['char']);
1497 1497
             
1498
-            if($amount > $max)
1498
+            if ($amount > $max)
1499 1499
             {
1500 1500
                 $max = $amount;
1501 1501
                 $results[] = $def;
1502 1502
             }
1503 1503
         }
1504 1504
         
1505
-        if(empty($results)) {
1505
+        if (empty($results)) {
1506 1506
             return null;
1507 1507
         }
1508 1508
         
@@ -1522,9 +1522,9 @@  discard block
 block discarded – undo
1522 1522
     */
1523 1523
     public static function arrayRemoveKeys(array &$array, array $keys) : void
1524 1524
     {
1525
-        foreach($keys as $key) 
1525
+        foreach ($keys as $key) 
1526 1526
         {
1527
-            if(array_key_exists($key, $array)) {
1527
+            if (array_key_exists($key, $array)) {
1528 1528
                 unset($array[$key]); 
1529 1529
             }
1530 1530
         }
@@ -1539,17 +1539,17 @@  discard block
 block discarded – undo
1539 1539
     */
1540 1540
     public static function isInteger($value) : bool
1541 1541
     {
1542
-        if(is_int($value)) {
1542
+        if (is_int($value)) {
1543 1543
             return true;
1544 1544
         }
1545 1545
         
1546 1546
         // booleans get converted to numbers, so they would
1547 1547
         // actually match the regex.
1548
-        if(is_bool($value)) {
1548
+        if (is_bool($value)) {
1549 1549
             return false;
1550 1550
         }
1551 1551
         
1552
-        if(is_string($value) && $value !== '') {
1552
+        if (is_string($value) && $value !== '') {
1553 1553
             return preg_match('/\A-?\d+\z/', $value) === 1;
1554 1554
         }
1555 1555
         
Please login to merge, or discard this patch.