Passed
Push — master ( 9fda08...16baae )
by Sebastian
06:39
created
src/ConvertHelper/ControlCharacters.php 2 patches
Indentation   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -22,9 +22,9 @@  discard block
 block discarded – undo
22 22
 {
23 23
     const ERROR_MALFORMATTED_STRING = 53801;
24 24
     
25
-   /**
26
-    * @var string[]
27
-    */
25
+    /**
26
+     * @var string[]
27
+     */
28 28
     protected static $controlChars =  array(
29 29
         '0000-0008', // control chars
30 30
         '000E-000F', // control chars
@@ -32,19 +32,19 @@  discard block
 block discarded – undo
32 32
         '2000-200F', // non-breaking space and co
33 33
     );
34 34
     
35
-   /**
36
-    * @var string|NULL
37
-    */
35
+    /**
36
+     * @var string|NULL
37
+     */
38 38
     protected static $controlCharsRegex;
39 39
 
40
-   /**
41
-    * @var string[]
42
-    */
40
+    /**
41
+     * @var string[]
42
+     */
43 43
     protected static $hexAlphabet = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F');
44 44
     
45
-   /**
46
-    * @var string[]|NULL
47
-    */
45
+    /**
46
+     * @var string[]|NULL
47
+     */
48 48
     protected static $charsAsHex;
49 49
     
50 50
     public function __construct()
@@ -67,13 +67,13 @@  discard block
 block discarded – undo
67 67
         }
68 68
     }
69 69
     
70
-   /**
71
-    * Retrieves the HEX character codes for all control
72
-    * characters that the {@link stripControlCharacters()}
73
-    * method will remove.
74
-    *
75
-    * @return string[]
76
-    */
70
+    /**
71
+     * Retrieves the HEX character codes for all control
72
+     * characters that the {@link stripControlCharacters()}
73
+     * method will remove.
74
+     *
75
+     * @return string[]
76
+     */
77 77
     public function getCharsAsHex() : array
78 78
     {
79 79
         if (isset(self::$charsAsHex))
@@ -120,13 +120,13 @@  discard block
 block discarded – undo
120 120
         return $stack;
121 121
     }
122 122
     
123
-   /**
124
-    * Retrieves an array of all control characters that
125
-    * the {@link stripControlCharacters()} method will
126
-    * remove, as the actual UTF-8 characters.
127
-    *
128
-    * @return string[]
129
-    */
123
+    /**
124
+     * Retrieves an array of all control characters that
125
+     * the {@link stripControlCharacters()} method will
126
+     * remove, as the actual UTF-8 characters.
127
+     *
128
+     * @return string[]
129
+     */
130 130
     public function getCharsAsUTF8() : array
131 131
     {
132 132
         $chars = $this->getCharsAsHex();
@@ -139,12 +139,12 @@  discard block
 block discarded – undo
139 139
         return $result;
140 140
     }
141 141
     
142
-   /**
143
-    * Retrieves all control characters as JSON encoded
144
-    * characters, e.g. "\u200b".
145
-    *
146
-    * @return string[]
147
-    */
142
+    /**
143
+     * Retrieves all control characters as JSON encoded
144
+     * characters, e.g. "\u200b".
145
+     *
146
+     * @return string[]
147
+     */
148 148
     public function getCharsAsJSON() : array
149 149
     {
150 150
         $chars = $this->getCharsAsHex();
@@ -157,17 +157,17 @@  discard block
 block discarded – undo
157 157
         return $result;
158 158
     }
159 159
     
160
-   /**
161
-    * Removes all control characters from the specified string
162
-    * that can cause problems in some cases, like creating
163
-    * valid XML documents. This includes invisible non-breaking
164
-    * spaces.
165
-    *
166
-    * @param string $string
167
-    * @return string
168
-    * @see https://stackoverflow.com/a/8171868/2298192
169
-    * @see https://unicode-table.com/en
170
-    */
160
+    /**
161
+     * Removes all control characters from the specified string
162
+     * that can cause problems in some cases, like creating
163
+     * valid XML documents. This includes invisible non-breaking
164
+     * spaces.
165
+     *
166
+     * @param string $string
167
+     * @return string
168
+     * @see https://stackoverflow.com/a/8171868/2298192
169
+     * @see https://unicode-table.com/en
170
+     */
171 171
     public function stripControlCharacters(string $string) : string
172 172
     {
173 173
         if(empty($string)) 
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
    /**
26 26
     * @var string[]
27 27
     */
28
-    protected static $controlChars =  array(
28
+    protected static $controlChars = array(
29 29
         '0000-0008', // control chars
30 30
         '000E-000F', // control chars
31 31
         '0010-001F', // control chars
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
     public function __construct()
51 51
     {
52 52
         // create the regex from the unicode characters list
53
-        if(!isset(self::$controlCharsRegex))
53
+        if (!isset(self::$controlCharsRegex))
54 54
         {
55 55
             $chars = $this->getCharsAsHex();
56 56
             
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
             // in the regular expression.
59 59
             $stack = array();
60 60
             
61
-            foreach($chars as $char) 
61
+            foreach ($chars as $char) 
62 62
             {
63 63
                 $stack[] = '\x{'.$char.'}';
64 64
             }
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
         
84 84
         $stack = array();
85 85
         
86
-        foreach(self::$controlChars as $char)
86
+        foreach (self::$controlChars as $char)
87 87
         {
88 88
             $tokens = explode('-', $char);
89 89
             $start = $tokens[0];
@@ -92,24 +92,24 @@  discard block
 block discarded – undo
92 92
             
93 93
             $range = array();
94 94
             
95
-            foreach(self::$hexAlphabet as $number) 
95
+            foreach (self::$hexAlphabet as $number) 
96 96
             {
97 97
                 $range[] = $prefix.$number;
98 98
             }
99 99
             
100 100
             $use = false;
101 101
             
102
-            foreach($range as $number) 
102
+            foreach ($range as $number) 
103 103
             {
104
-                if($number == $start) {
104
+                if ($number == $start) {
105 105
                     $use = true;
106 106
                 }
107 107
                 
108
-                if($use) {
108
+                if ($use) {
109 109
                     $stack[] = $number;
110 110
                 }
111 111
                 
112
-                if($number == $end) {
112
+                if ($number == $end) {
113 113
                     break;
114 114
                 }
115 115
             }
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
         $chars = $this->getCharsAsHex();
133 133
         
134 134
         $result = array();
135
-        foreach($chars as $char) {
135
+        foreach ($chars as $char) {
136 136
             $result[] = hex2bin($char);
137 137
         }
138 138
         
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
         $chars = $this->getCharsAsHex();
151 151
         
152 152
         $result = array();
153
-        foreach($chars as $char) {
153
+        foreach ($chars as $char) {
154 154
             $result[] = '\u'.strtolower($char);
155 155
         }
156 156
         
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
     */
171 171
     public function stripControlCharacters(string $string) : string
172 172
     {
173
-        if(empty($string)) 
173
+        if (empty($string)) 
174 174
         {
175 175
             return $string;
176 176
         }
@@ -178,13 +178,13 @@  discard block
 block discarded – undo
178 178
         $result = preg_replace(self::$controlCharsRegex, '', $string);
179 179
         
180 180
         // can happen if the text contains invalid UTF8
181
-        if($result === null)
181
+        if ($result === null)
182 182
         {
183 183
             $string = ConvertHelper::string2utf8($string);
184 184
             
185 185
             $result = preg_replace(self::$controlCharsRegex, '', $string);
186 186
             
187
-            if($result === null)
187
+            if ($result === null)
188 188
             {
189 189
                 throw new ConvertHelper_Exception(
190 190
                     'Cannot strip control characters: malformatted string encountered.',
Please login to merge, or discard this patch.
src/functions.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -14,9 +14,9 @@  discard block
 block discarded – undo
14 14
  * @param mixed $value
15 15
  * @return \AppUtils\NumberInfo
16 16
  */
17
-function parseNumber($value, $forceNew=false)
17
+function parseNumber($value, $forceNew = false)
18 18
 {
19
-    if($value instanceof NumberInfo && $forceNew !== true) {
19
+    if ($value instanceof NumberInfo && $forceNew !== true) {
20 20
         return $value;
21 21
     }
22 22
     
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
     $args = func_get_args();
98 98
     
99 99
     // is the localization package installed?
100
-    if(class_exists('\AppLocalize\Localization')) 
100
+    if (class_exists('\AppLocalize\Localization')) 
101 101
     {
102 102
         return call_user_func_array('\AppLocalize\t', $args);
103 103
     }
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
  */
116 116
 function requireCURL() : void
117 117
 {
118
-    if(function_exists('curl_init')) {
118
+    if (function_exists('curl_init')) {
119 119
         return;
120 120
     }
121 121
     
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
  * @param bool $initial The initial boolean value to use.
133 133
  * @return Value_Bool
134 134
  */
135
-function valBool(bool $initial=false) : Value_Bool
135
+function valBool(bool $initial = false) : Value_Bool
136 136
 {
137 137
     return new Value_Bool($initial);
138 138
 }
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
  * @param bool $initial
146 146
  * @return Value_Bool_True
147 147
  */
148
-function valBoolTrue(bool $initial=false) : Value_Bool_True
148
+function valBoolTrue(bool $initial = false) : Value_Bool_True
149 149
 {
150 150
     return new Value_Bool_True($initial);
151 151
 }
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
  * @param bool $initial
159 159
  * @return Value_Bool_False
160 160
  */
161
-function valBoolFalse(bool $initial=true) : Value_Bool_False
161
+function valBoolFalse(bool $initial = true) : Value_Bool_False
162 162
 {
163 163
     return new Value_Bool_False($initial);
164 164
 }
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
  */
171 171
 function init()
172 172
 {
173
-    if(!class_exists('\AppLocalize\Localization')) {
173
+    if (!class_exists('\AppLocalize\Localization')) {
174 174
         return;
175 175
     }
176 176
     
Please login to merge, or discard this patch.
src/Value/Bool.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@
 block discarded – undo
21 21
 {
22 22
     protected $value = false;
23 23
     
24
-    public function __construct(bool $value=false)
24
+    public function __construct(bool $value = false)
25 25
     {
26 26
         $this->value = $value;
27 27
     }
Please login to merge, or discard this patch.
src/Value/Bool/False.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -22,14 +22,14 @@
 block discarded – undo
22 22
  */
23 23
 class Value_Bool_False extends Value_Bool
24 24
 {
25
-    public function __construct(bool $value=true)
25
+    public function __construct(bool $value = true)
26 26
     {
27 27
         parent::__construct($value);
28 28
     }
29 29
     
30 30
     public function set(bool $value) : Value_Bool
31 31
     {
32
-        if($value === false)
32
+        if ($value === false)
33 33
         {
34 34
             parent::set($value);
35 35
         }
Please login to merge, or discard this patch.
src/Value/Bool/True.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@
 block discarded – undo
24 24
 {
25 25
     public function set(bool $value) : Value_Bool
26 26
     {
27
-        if($value === true)
27
+        if ($value === true)
28 28
         {
29 29
             parent::set($value);
30 30
         }
Please login to merge, or discard this patch.
src/ConvertHelper/URLFinder.php 2 patches
Indentation   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -22,14 +22,14 @@  discard block
 block discarded – undo
22 22
  */
23 23
 class ConvertHelper_URLFinder
24 24
 {
25
-   /**
26
-    * @var string
27
-    */
25
+    /**
26
+     * @var string
27
+     */
28 28
     protected $subject;
29 29
     
30
-   /**
31
-    * @var boolean
32
-    */
30
+    /**
31
+     * @var boolean
32
+     */
33 33
     protected $sorting = false;
34 34
     
35 35
     protected $schemes = array(
@@ -48,12 +48,12 @@  discard block
 block discarded – undo
48 48
         $this->subject = $subject;
49 49
     }
50 50
     
51
-   /**
52
-    * Whether to enable sorting the URLs alphabetically (disabled by default).
53
-    * 
54
-    * @param bool $enabled
55
-    * @return ConvertHelper_URLFinder
56
-    */
51
+    /**
52
+     * Whether to enable sorting the URLs alphabetically (disabled by default).
53
+     * 
54
+     * @param bool $enabled
55
+     * @return ConvertHelper_URLFinder
56
+     */
57 57
     public function enableSorting(bool $enabled=true) : ConvertHelper_URLFinder
58 58
     {
59 59
         $this->sorting = $enabled;
@@ -61,11 +61,11 @@  discard block
 block discarded – undo
61 61
         return $this;
62 62
     }
63 63
     
64
-   /**
65
-    * Prepares the subject string by adding a newline before all URL schemes,
66
-    * to make it possible to parse even lists of links separated by commas or
67
-    * the like (http://domain.com,http://domain2.com).
68
-    */
64
+    /**
65
+     * Prepares the subject string by adding a newline before all URL schemes,
66
+     * to make it possible to parse even lists of links separated by commas or
67
+     * the like (http://domain.com,http://domain2.com).
68
+     */
69 69
     protected function prepareSubject() : void
70 70
     {
71 71
         $replaces = array();
@@ -78,13 +78,13 @@  discard block
 block discarded – undo
78 78
         $this->subject = str_replace(array_keys($replaces), array_values($replaces), $this->subject);
79 79
     }
80 80
     
81
-   /**
82
-    * Fetches all URLs that can be found in the subject string.
83
-    * 
84
-    * @return string[]
85
-    * 
86
-    * @see https://gist.github.com/gruber/249502
87
-    */
81
+    /**
82
+     * Fetches all URLs that can be found in the subject string.
83
+     * 
84
+     * @return string[]
85
+     * 
86
+     * @see https://gist.github.com/gruber/249502
87
+     */
88 88
     public function getURLs() : array
89 89
     {
90 90
         $this->prepareSubject();
@@ -115,11 +115,11 @@  discard block
 block discarded – undo
115 115
         return $result;
116 116
     }
117 117
     
118
-   /**
119
-    * Retrieves all URLs as URLInfo instances.
120
-    * 
121
-    * @return URLInfo[]
122
-    */
118
+    /**
119
+     * Retrieves all URLs as URLInfo instances.
120
+     * 
121
+     * @return URLInfo[]
122
+     */
123 123
     public function getInfos()
124 124
     {
125 125
         $urls = $this->getURLs();
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
     * @param bool $enabled
55 55
     * @return ConvertHelper_URLFinder
56 56
     */
57
-    public function enableSorting(bool $enabled=true) : ConvertHelper_URLFinder
57
+    public function enableSorting(bool $enabled = true) : ConvertHelper_URLFinder
58 58
     {
59 59
         $this->sorting = $enabled;
60 60
         
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
     {
71 71
         $replaces = array();
72 72
         
73
-        foreach($this->schemes as $scheme)
73
+        foreach ($this->schemes as $scheme)
74 74
         {
75 75
             $replaces[$scheme.':'] = PHP_EOL.$scheme.':';
76 76
         }
@@ -94,18 +94,18 @@  discard block
 block discarded – undo
94 94
         
95 95
         $result = array();
96 96
         
97
-        if(is_array($matches))
97
+        if (is_array($matches))
98 98
         {
99
-            foreach($matches[0] as $match)
99
+            foreach ($matches[0] as $match)
100 100
             {
101
-                if(strstr($match, '://') && !in_array($match, $result))
101
+                if (strstr($match, '://') && !in_array($match, $result))
102 102
                 {
103 103
                     $result[] = $match;
104 104
                 }
105 105
             }
106 106
         }
107 107
         
108
-        if($this->sorting)
108
+        if ($this->sorting)
109 109
         {
110 110
             usort($result, function(string $a, string $b) {
111 111
                 return strnatcasecmp($a, $b);
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
         
127 127
         $result = array();
128 128
         
129
-        foreach($urls as $url)
129
+        foreach ($urls as $url)
130 130
         {
131 131
             $result[] = parseURL($url);
132 132
         }
Please login to merge, or discard this patch.
src/VariableInfo/Renderer/String/Array.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -13,15 +13,15 @@
 block discarded – undo
13 13
         return print_r($result, true);
14 14
     }
15 15
     
16
-    protected function traverseArray(array $array, int $level=0) : array
16
+    protected function traverseArray(array $array, int $level = 0) : array
17 17
     {
18 18
         $result = array();
19 19
         
20
-        foreach($array as $key => $val)
20
+        foreach ($array as $key => $val)
21 21
         {
22
-            if(is_array($val))
22
+            if (is_array($val))
23 23
             {
24
-                $result[$key] = $this->traverseArray($val, ($level+1));
24
+                $result[$key] = $this->traverseArray($val, ($level + 1));
25 25
             }
26 26
             else
27 27
             {
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -22,8 +22,7 @@
 block discarded – undo
22 22
             if(is_array($val))
23 23
             {
24 24
                 $result[$key] = $this->traverseArray($val, ($level+1));
25
-            }
26
-            else
25
+            } else
27 26
             {
28 27
                 $result[$key] = parseVariable($val)->toString();
29 28
             }
Please login to merge, or discard this patch.
src/XMLHelper/SimpleXML.php 2 patches
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -23,37 +23,37 @@
 block discarded – undo
23 23
 {
24 24
     const ERROR_NOT_LOADED_YET = 56501;
25 25
     
26
-   /**
27
-    * @var \SimpleXMLElement|NULL
28
-    */
26
+    /**
27
+     * @var \SimpleXMLElement|NULL
28
+     */
29 29
     private $element = null;
30 30
     
31
-   /**
32
-    * @var XMLHelper_SimpleXML_Error[]
33
-    */
31
+    /**
32
+     * @var XMLHelper_SimpleXML_Error[]
33
+     */
34 34
     private $errors = array();
35 35
     
36
-   /**
37
-    * Creates a simplexml instance from an XML string.
38
-    *
39
-    * NOTE: returns false in case of a fatal error.
40
-    *
41
-    * @param string $string
42
-    * @return \SimpleXMLElement|NULL
43
-    */
36
+    /**
37
+     * Creates a simplexml instance from an XML string.
38
+     *
39
+     * NOTE: returns false in case of a fatal error.
40
+     *
41
+     * @param string $string
42
+     * @return \SimpleXMLElement|NULL
43
+     */
44 44
     public function loadString(string $string) : ?\SimpleXMLElement
45 45
     {
46 46
         return $this->load('string', $string);
47 47
     }
48 48
     
49
-   /**
50
-    * Creates a simplexml instance from an XML file.
51
-    * 
52
-    * NOTE: returns false in case of a fatal error.
53
-    * 
54
-    * @param string $file
55
-    * @return \SimpleXMLElement|NULL
56
-    */
49
+    /**
50
+     * Creates a simplexml instance from an XML file.
51
+     * 
52
+     * NOTE: returns false in case of a fatal error.
53
+     * 
54
+     * @param string $file
55
+     * @return \SimpleXMLElement|NULL
56
+     */
57 57
     public function loadFile(string $file) : ?\SimpleXMLElement
58 58
     {
59 59
         return $this->load('file', $file);
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
         // error wrappers.
84 84
         $errors = libxml_get_errors();
85 85
         
86
-        foreach($errors as $error) 
86
+        foreach ($errors as $error) 
87 87
         {
88 88
             $this->errors[] = new XMLHelper_SimpleXML_Error($this, $error);
89 89
         }
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
         
98 98
         $xml = $function($subject);
99 99
         
100
-        if($xml instanceof \SimpleXMLElement)
100
+        if ($xml instanceof \SimpleXMLElement)
101 101
         {
102 102
             return $xml;
103 103
         }
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
     
108 108
     public function getConverter() : XMLHelper_Converter
109 109
     {
110
-        if($this->element instanceof \SimpleXMLElement)
110
+        if ($this->element instanceof \SimpleXMLElement)
111 111
         {
112 112
             return XMLHelper::convertElement($this->element);
113 113
         }
Please login to merge, or discard this patch.