@@ -18,7 +18,8 @@ |
||
18 | 18 | $columns = array_shift($rows); |
19 | 19 | $csv = []; |
20 | 20 | |
21 | - foreach ($rows as $row) { |
|
21 | + foreach ($rows as $row) |
|
22 | + { |
|
22 | 23 | $csv[] = array_combine($columns, $row); |
23 | 24 | } |
24 | 25 |
@@ -16,14 +16,16 @@ |
||
16 | 16 | */ |
17 | 17 | public static function transformData($content): array |
18 | 18 | { |
19 | - if (!function_exists('simplexml_load_string')) { |
|
19 | + if (!function_exists('simplexml_load_string')) |
|
20 | + { |
|
20 | 21 | throw new DependencyMissingException('XML', 'XML support is not available with the current PHP installation.'); |
21 | 22 | } |
22 | 23 | |
23 | 24 | libxml_use_internal_errors(true); |
24 | 25 | $data = json_decode(json_encode(simplexml_load_string($content), JSON_THROW_ON_ERROR), true, 512, JSON_THROW_ON_ERROR); |
25 | 26 | |
26 | - if ($data === false || $data === null) { |
|
27 | + if ($data === false || $data === null) |
|
28 | + { |
|
27 | 29 | return []; |
28 | 30 | } |
29 | 31 |
@@ -17,13 +17,17 @@ |
||
17 | 17 | */ |
18 | 18 | public static function transformData($content): array |
19 | 19 | { |
20 | - try { |
|
20 | + try |
|
21 | + { |
|
21 | 22 | $data = Yaml::parse($content, Yaml::PARSE_DATETIME); |
22 | - } catch (Exception) { |
|
23 | + } |
|
24 | + catch (Exception) |
|
25 | + { |
|
23 | 26 | return []; |
24 | 27 | } |
25 | 28 | |
26 | - if ($data === null) { |
|
29 | + if ($data === null) |
|
30 | + { |
|
27 | 31 | return []; |
28 | 32 | } |
29 | 33 |
@@ -20,21 +20,24 @@ |
||
20 | 20 | |
21 | 21 | public function addDataTransformers(/* iterable */ $dataTransformers): void |
22 | 22 | { |
23 | - foreach ($dataTransformers as $dataTransformer) { |
|
23 | + foreach ($dataTransformers as $dataTransformer) |
|
24 | + { |
|
24 | 25 | $this->addDataTransformer($dataTransformer); |
25 | 26 | } |
26 | 27 | } |
27 | 28 | |
28 | 29 | public function addDataTransformer(DataTransformerInterface $transformer): void |
29 | 30 | { |
30 | - foreach ($transformer->getExtensions() as $extension) { |
|
31 | + foreach ($transformer->getExtensions() as $extension) |
|
32 | + { |
|
31 | 33 | $this->transformers[$extension] = $transformer; |
32 | 34 | } |
33 | 35 | } |
34 | 36 | |
35 | 37 | public function getTransformer($extension) |
36 | 38 | { |
37 | - if (isset($this->transformers[$extension])) { |
|
39 | + if (isset($this->transformers[$extension])) |
|
40 | + { |
|
38 | 41 | return $this->transformers[$extension]; |
39 | 42 | } |
40 | 43 |
@@ -13,7 +13,7 @@ |
||
13 | 13 | |
14 | 14 | abstract class HtmlUtils |
15 | 15 | { |
16 | - public static function htmlXPath(DOMDocument &$DOMDocument, $html, $xpathQuery) |
|
16 | + public static function htmlXPath(DOMDocument & $DOMDocument, $html, $xpathQuery) |
|
17 | 17 | { |
18 | 18 | $html = self::normalizeHTML($html); |
19 | 19 |
@@ -27,10 +27,12 @@ discard block |
||
27 | 27 | $xmlErrors = libxml_get_errors(); |
28 | 28 | |
29 | 29 | /** @var LibXMLError $error */ |
30 | - foreach ($xmlErrors as $error) { |
|
30 | + foreach ($xmlErrors as $error) |
|
31 | + { |
|
31 | 32 | // Ignore errors about invalid tags |
32 | 33 | // http://www.xmlsoft.org/html/libxml-xmlerror.html#xmlParserErrors |
33 | - if ($error->code === 801) { |
|
34 | + if ($error->code === 801) |
|
35 | + { |
|
34 | 36 | continue; |
35 | 37 | } |
36 | 38 | |
@@ -46,7 +48,8 @@ discard block |
||
46 | 48 | |
47 | 49 | private static function normalizeHTML($html) |
48 | 50 | { |
49 | - if (!str_contains((string)$html, '<body>') || !str_contains((string)$html, '</body>')) { |
|
51 | + if (!str_contains((string)$html, '<body>') || !str_contains((string)$html, '</body>')) |
|
52 | + { |
|
50 | 53 | return sprintf('<body>%s</body>', $html); |
51 | 54 | } |
52 | 55 |
@@ -11,8 +11,10 @@ discard block |
||
11 | 11 | { |
12 | 12 | public static function is_multidimensional(array &$array): bool |
13 | 13 | { |
14 | - foreach ($array as &$element) { |
|
15 | - if (is_array($element)) { |
|
14 | + foreach ($array as &$element) |
|
15 | + { |
|
16 | + if (is_array($element)) |
|
17 | + { |
|
16 | 18 | return true; |
17 | 19 | } |
18 | 20 | } |
@@ -37,8 +39,10 @@ discard block |
||
37 | 39 | */ |
38 | 40 | public static function array_can_be_indexed(array &$arr, $indexKey): bool |
39 | 41 | { |
40 | - foreach ($arr as &$value) { |
|
41 | - if (isset($value[$indexKey]) && is_scalar($value[$indexKey])) { |
|
42 | + foreach ($arr as &$value) |
|
43 | + { |
|
44 | + if (isset($value[$indexKey]) && is_scalar($value[$indexKey])) |
|
45 | + { |
|
42 | 46 | return true; |
43 | 47 | } |
44 | 48 | } |
@@ -69,8 +73,10 @@ discard block |
||
69 | 73 | { |
70 | 74 | $result = []; |
71 | 75 | |
72 | - foreach ($arr as &$value) { |
|
73 | - if (isset($value[$indexKey]) && is_scalar($value[$indexKey])) { |
|
76 | + foreach ($arr as &$value) |
|
77 | + { |
|
78 | + if (isset($value[$indexKey]) && is_scalar($value[$indexKey])) |
|
79 | + { |
|
74 | 80 | $result[$value[$indexKey]] = $value; |
75 | 81 | } |
76 | 82 | } |
@@ -91,13 +97,18 @@ discard block |
||
91 | 97 | { |
92 | 98 | $merged = $arr1; |
93 | 99 | |
94 | - foreach ($arr2 as $key => &$value) { |
|
95 | - if (is_array($value) && isset($arr1[$key])) { |
|
96 | - if (self::array_can_be_indexed($value, $indexKey)) { |
|
100 | + foreach ($arr2 as $key => &$value) |
|
101 | + { |
|
102 | + if (is_array($value) && isset($arr1[$key])) |
|
103 | + { |
|
104 | + if (self::array_can_be_indexed($value, $indexKey)) |
|
105 | + { |
|
97 | 106 | $indexedArr1 = self::array_index_by_key($arr1[$key], $indexKey); |
98 | 107 | $indexedArr2 = self::array_index_by_key($value, $indexKey); |
99 | 108 | $merged[$key] = array_merge($indexedArr1, $indexedArr2); |
100 | - } else { |
|
109 | + } |
|
110 | + else |
|
111 | + { |
|
101 | 112 | $merged[$key] = array_merge($arr1[$key], $value); |
102 | 113 | } |
103 | 114 |
@@ -28,7 +28,8 @@ discard block |
||
28 | 28 | */ |
29 | 29 | public function offsetGet($offset): mixed |
30 | 30 | { |
31 | - if (isset($this->data[$offset])) { |
|
31 | + if (isset($this->data[$offset])) |
|
32 | + { |
|
32 | 33 | return $this->data[$offset]; |
33 | 34 | } |
34 | 35 | |
@@ -40,7 +41,8 @@ discard block |
||
40 | 41 | */ |
41 | 42 | public function offsetSet($offset, $value): void |
42 | 43 | { |
43 | - if ($offset === null) { |
|
44 | + if ($offset === null) |
|
45 | + { |
|
44 | 46 | return; |
45 | 47 | } |
46 | 48 | |
@@ -52,7 +54,8 @@ discard block |
||
52 | 54 | */ |
53 | 55 | public function offsetUnset($offset): void |
54 | 56 | { |
55 | - if (isset($this->data[$offset])) { |
|
57 | + if (isset($this->data[$offset])) |
|
58 | + { |
|
56 | 59 | unset($this->data[$offset]); |
57 | 60 | } |
58 | 61 | } |
@@ -21,8 +21,10 @@ discard block |
||
21 | 21 | // build a replacement array with braces around the context keys |
22 | 22 | $replace = []; |
23 | 23 | |
24 | - foreach ($context as $key => $val) { |
|
25 | - if (!is_array($val) && (!is_object($val) || method_exists($val, '__toString'))) { |
|
24 | + foreach ($context as $key => $val) |
|
25 | + { |
|
26 | + if (!is_array($val) && (!is_object($val) || method_exists($val, '__toString'))) |
|
27 | + { |
|
26 | 28 | $replace[sprintf('{%s}', $key)] = $val; |
27 | 29 | } |
28 | 30 | } |
@@ -38,7 +40,8 @@ discard block |
||
38 | 40 | */ |
39 | 41 | public static function canBeCastedToString(mixed $mixed): bool |
40 | 42 | { |
41 | - if (is_string($mixed)) { |
|
43 | + if (is_string($mixed)) |
|
44 | + { |
|
42 | 45 | return true; |
43 | 46 | } |
44 | 47 |
@@ -108,7 +108,7 @@ |
||
108 | 108 | * @param int $options A bitmask of options (one of the OUTPUT or VERBOSITY constants), 0 is considered |
109 | 109 | * the same as self::OUTPUT_NORMAL | self::VERBOSITY_NORMAL |
110 | 110 | */ |
111 | - public function writeln(string|array $messages, $options = 0) |
|
111 | + public function writeln(string | array $messages, $options = 0) |
|
112 | 112 | { |
113 | 113 | $this->output->writeln($messages, $options); |
114 | 114 | } |