@@ -14,9 +14,9 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
@@ -21,7 +21,7 @@ |
||
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 | } |
@@ -22,14 +22,14 @@ |
||
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 | } |
@@ -24,7 +24,7 @@ |
||
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 | } |
@@ -22,14 +22,14 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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(); |
@@ -54,7 +54,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 | } |
@@ -13,15 +13,15 @@ |
||
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 | { |
@@ -22,8 +22,7 @@ |
||
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 | } |
@@ -23,37 +23,37 @@ |
||
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); |
@@ -83,7 +83,7 @@ discard block |
||
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 |
||
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 |
||
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 | } |
@@ -24,9 +24,9 @@ |
||
24 | 24 | const ERROR_CANNOT_UNSERIALIZE_ERROR_DATA = 57201; |
25 | 25 | const ERROR_ERROR_DATA_KEY_MISSING = 57202; |
26 | 26 | |
27 | - /** |
|
28 | - * @var \LibXMLError |
|
29 | - */ |
|
27 | + /** |
|
28 | + * @var \LibXMLError |
|
29 | + */ |
|
30 | 30 | private $error; |
31 | 31 | |
32 | 32 | private static $requiredKeys = array( |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | { |
47 | 47 | $data = @json_decode($serialized, true); |
48 | 48 | |
49 | - if(!is_array($data)) |
|
49 | + if (!is_array($data)) |
|
50 | 50 | { |
51 | 51 | throw new XMLHelper_Exception( |
52 | 52 | 'Could not unserialize error data', |
@@ -72,9 +72,9 @@ discard block |
||
72 | 72 | |
73 | 73 | private static function checkErrorData(array $data) : void |
74 | 74 | { |
75 | - foreach(self::$requiredKeys as $key) |
|
75 | + foreach (self::$requiredKeys as $key) |
|
76 | 76 | { |
77 | - if(!array_key_exists($key, $data)) |
|
77 | + if (!array_key_exists($key, $data)) |
|
78 | 78 | { |
79 | 79 | throw new XMLHelper_Exception( |
80 | 80 | 'Required key missing in error data', |
@@ -36,19 +36,19 @@ discard block |
||
36 | 36 | { |
37 | 37 | const ERROR_STRING_ALREADY_HAS_BODY_TAG = 57001; |
38 | 38 | |
39 | - /** |
|
40 | - * @var \DOMElement |
|
41 | - */ |
|
39 | + /** |
|
40 | + * @var \DOMElement |
|
41 | + */ |
|
42 | 42 | private $bodyNode; |
43 | 43 | |
44 | - /** |
|
45 | - * @var XMLHelper_DOMErrors |
|
46 | - */ |
|
44 | + /** |
|
45 | + * @var XMLHelper_DOMErrors |
|
46 | + */ |
|
47 | 47 | private $errors; |
48 | 48 | |
49 | - /** |
|
50 | - * @var string |
|
51 | - */ |
|
49 | + /** |
|
50 | + * @var string |
|
51 | + */ |
|
52 | 52 | private static $htmlTemplate = |
53 | 53 | '<!DOCTYPE html>'. |
54 | 54 | '<html>'. |
@@ -60,9 +60,9 @@ discard block |
||
60 | 60 | '</body>'. |
61 | 61 | '</html>'; |
62 | 62 | |
63 | - /** |
|
64 | - * @var \DOMDocument |
|
65 | - */ |
|
63 | + /** |
|
64 | + * @var \DOMDocument |
|
65 | + */ |
|
66 | 66 | private $dom; |
67 | 67 | |
68 | 68 | private function __construct(string $html) |
@@ -70,13 +70,13 @@ discard block |
||
70 | 70 | $this->load($html); |
71 | 71 | } |
72 | 72 | |
73 | - /** |
|
74 | - * Creates an HTML loader from an HTML fragment (without |
|
75 | - * doctype, head and body elements). |
|
76 | - * |
|
77 | - * @param string $fragment |
|
78 | - * @return XMLHelper_HTMLLoader |
|
79 | - */ |
|
73 | + /** |
|
74 | + * Creates an HTML loader from an HTML fragment (without |
|
75 | + * doctype, head and body elements). |
|
76 | + * |
|
77 | + * @param string $fragment |
|
78 | + * @return XMLHelper_HTMLLoader |
|
79 | + */ |
|
80 | 80 | public static function loadFragment(string $fragment) : XMLHelper_HTMLLoader |
81 | 81 | { |
82 | 82 | self::checkFragment($fragment); |
@@ -87,24 +87,24 @@ discard block |
||
87 | 87 | return new XMLHelper_HTMLLoader($pseudoHTML); |
88 | 88 | } |
89 | 89 | |
90 | - /** |
|
91 | - * Creates an HTML loader from a full HTML document (including |
|
92 | - * doctype, head and body elements). |
|
93 | - * |
|
94 | - * @param string $html |
|
95 | - * @return XMLHelper_HTMLLoader |
|
96 | - */ |
|
90 | + /** |
|
91 | + * Creates an HTML loader from a full HTML document (including |
|
92 | + * doctype, head and body elements). |
|
93 | + * |
|
94 | + * @param string $html |
|
95 | + * @return XMLHelper_HTMLLoader |
|
96 | + */ |
|
97 | 97 | public static function loadHTML(string $html) : XMLHelper_HTMLLoader |
98 | 98 | { |
99 | 99 | return new XMLHelper_HTMLLoader($html); |
100 | 100 | } |
101 | 101 | |
102 | - /** |
|
103 | - * Verifies that the fragment does not already contain a body element or doctype. |
|
104 | - * |
|
105 | - * @param string $fragment |
|
106 | - * @throws XMLHelper_Exception |
|
107 | - */ |
|
102 | + /** |
|
103 | + * Verifies that the fragment does not already contain a body element or doctype. |
|
104 | + * |
|
105 | + * @param string $fragment |
|
106 | + * @throws XMLHelper_Exception |
|
107 | + */ |
|
108 | 108 | private static function checkFragment(string $fragment) : void |
109 | 109 | { |
110 | 110 | if(!stristr($fragment, '<body') && !stristr($fragment, 'doctype')) |
@@ -142,65 +142,65 @@ discard block |
||
142 | 142 | return $this->bodyNode; |
143 | 143 | } |
144 | 144 | |
145 | - /** |
|
146 | - * Retrieves the document's `<body>` tag node. |
|
147 | - * |
|
148 | - * @return \DOMDocument |
|
149 | - */ |
|
145 | + /** |
|
146 | + * Retrieves the document's `<body>` tag node. |
|
147 | + * |
|
148 | + * @return \DOMDocument |
|
149 | + */ |
|
150 | 150 | public function getDOM() : \DOMDocument |
151 | 151 | { |
152 | 152 | return $this->dom; |
153 | 153 | } |
154 | 154 | |
155 | - /** |
|
156 | - * Retrieves all nodes from the HTML fragment (= child nodes |
|
157 | - * of the `<body>` element). |
|
158 | - * |
|
159 | - * @return \DOMNodeList |
|
160 | - */ |
|
155 | + /** |
|
156 | + * Retrieves all nodes from the HTML fragment (= child nodes |
|
157 | + * of the `<body>` element). |
|
158 | + * |
|
159 | + * @return \DOMNodeList |
|
160 | + */ |
|
161 | 161 | public function getFragmentNodes() : \DOMNodeList |
162 | 162 | { |
163 | 163 | return $this->bodyNode->childNodes; |
164 | 164 | } |
165 | 165 | |
166 | - /** |
|
167 | - * Retrieves the LibXML HTML parsing errors collection, which |
|
168 | - * can be used to review any errors that occurred while loading |
|
169 | - * the HTML document. |
|
170 | - * |
|
171 | - * @return XMLHelper_DOMErrors |
|
172 | - */ |
|
166 | + /** |
|
167 | + * Retrieves the LibXML HTML parsing errors collection, which |
|
168 | + * can be used to review any errors that occurred while loading |
|
169 | + * the HTML document. |
|
170 | + * |
|
171 | + * @return XMLHelper_DOMErrors |
|
172 | + */ |
|
173 | 173 | public function getErrors() : XMLHelper_DOMErrors |
174 | 174 | { |
175 | 175 | return $this->errors; |
176 | 176 | } |
177 | 177 | |
178 | - /** |
|
179 | - * Returns a valid HTML string. |
|
180 | - * |
|
181 | - * @return string |
|
182 | - */ |
|
178 | + /** |
|
179 | + * Returns a valid HTML string. |
|
180 | + * |
|
181 | + * @return string |
|
182 | + */ |
|
183 | 183 | public function toHTML() : string |
184 | 184 | { |
185 | 185 | return $this->dom->saveHTML(); |
186 | 186 | } |
187 | 187 | |
188 | - /** |
|
189 | - * Returns a valid XML string. |
|
190 | - * |
|
191 | - * @return string |
|
192 | - */ |
|
188 | + /** |
|
189 | + * Returns a valid XML string. |
|
190 | + * |
|
191 | + * @return string |
|
192 | + */ |
|
193 | 193 | public function toXML() : string |
194 | 194 | { |
195 | 195 | return $this->dom->saveXML(); |
196 | 196 | } |
197 | 197 | |
198 | - /** |
|
199 | - * Converts the HTML fragment to valid XML (= all |
|
200 | - * child nodes of the `<body>` element). |
|
201 | - * |
|
202 | - * @return string |
|
203 | - */ |
|
198 | + /** |
|
199 | + * Converts the HTML fragment to valid XML (= all |
|
200 | + * child nodes of the `<body>` element). |
|
201 | + * |
|
202 | + * @return string |
|
203 | + */ |
|
204 | 204 | public function fragmentToXML() : string |
205 | 205 | { |
206 | 206 | $nodes = $this->getFragmentNodes(); |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | */ |
108 | 108 | private static function checkFragment(string $fragment) : void |
109 | 109 | { |
110 | - if(!stristr($fragment, '<body') && !stristr($fragment, 'doctype')) |
|
110 | + if (!stristr($fragment, '<body') && !stristr($fragment, 'doctype')) |
|
111 | 111 | { |
112 | 112 | return; |
113 | 113 | } |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | |
208 | 208 | // capture all elements except the body tag itself |
209 | 209 | $xml = ''; |
210 | - foreach($nodes as $child) |
|
210 | + foreach ($nodes as $child) |
|
211 | 211 | { |
212 | 212 | $xml .= $this->dom->saveXML($child); |
213 | 213 | } |