@@ -18,15 +18,15 @@ discard block |
||
| 18 | 18 | |
| 19 | 19 | public function parse() |
| 20 | 20 | {
|
| 21 | - return [$this->getValue()->documentElement->tagName => |
|
| 22 | - $this->convert($this->value->documentElement)]; |
|
| 21 | + return [ $this->getValue()->documentElement->tagName => |
|
| 22 | + $this->convert($this->value->documentElement) ]; |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | - public function convert($node, $output = []) |
|
| 25 | + public function convert($node, $output = [ ]) |
|
| 26 | 26 | {
|
| 27 | 27 | switch ($node->nodeType) {
|
| 28 | 28 | case XML_CDATA_SECTION_NODE: |
| 29 | - $output['@cdata'] = trim($node->textContent); |
|
| 29 | + $output[ '@cdata' ] = trim($node->textContent); |
|
| 30 | 30 | break; |
| 31 | 31 | case XML_TEXT_NODE: |
| 32 | 32 | $output = trim($node->textContent); |
@@ -45,17 +45,17 @@ discard block |
||
| 45 | 45 | return $this->attributes($node, $output); |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | - private function childNode($node, $output = []) |
|
| 48 | + private function childNode($node, $output = [ ]) |
|
| 49 | 49 | {
|
| 50 | 50 | foreach ($node->childNodes as $child) {
|
| 51 | 51 | $children = $this->convert($child); |
| 52 | 52 | |
| 53 | 53 | if (isset($child->tagName)) {
|
| 54 | 54 | $tagName = $child->tagName; |
| 55 | - $output[$tagName] = isset($output[$tagName]) |
|
| 56 | - ? $output[$tagName] |
|
| 57 | - : []; |
|
| 58 | - $output[$tagName][] = $children; |
|
| 55 | + $output[ $tagName ] = isset($output[ $tagName ]) |
|
| 56 | + ? $output[ $tagName ] |
|
| 57 | + : [ ]; |
|
| 58 | + $output[ $tagName ][ ] = $children; |
|
| 59 | 59 | } elseif ($children !== '') {
|
| 60 | 60 | $output = $children; |
| 61 | 61 | } |
@@ -63,11 +63,11 @@ discard block |
||
| 63 | 63 | return $output; |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | - private function loopAttributes($attributes, $array = []) |
|
| 66 | + private function loopAttributes($attributes, $array = [ ]) |
|
| 67 | 67 | {
|
| 68 | 68 | // Loop through the attributes and collect them. |
| 69 | 69 | foreach ($attributes as $key => $node) {
|
| 70 | - $array[$key] = (string) $node->value; |
|
| 70 | + $array[ $key ] = (string) $node->value; |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | return $array; |
@@ -77,8 +77,8 @@ discard block |
||
| 77 | 77 | {
|
| 78 | 78 | // If there are attributes. |
| 79 | 79 | if ($node->attributes->length) {
|
| 80 | - $output = is_array($output) ? $output : ['@value' => $output]; |
|
| 81 | - $output['@attributes'] = $this->loopAttributes($node->attributes); |
|
| 80 | + $output = is_array($output) ? $output : [ '@value' => $output ]; |
|
| 81 | + $output[ '@attributes' ] = $this->loopAttributes($node->attributes); |
|
| 82 | 82 | } |
| 83 | 83 | return $output; |
| 84 | 84 | } |
@@ -87,8 +87,8 @@ discard block |
||
| 87 | 87 | {
|
| 88 | 88 | if (is_array($output)) {
|
| 89 | 89 | foreach ($output as $key => $value) {
|
| 90 | - $output[$key] = is_array($value) && count($value) === 1 |
|
| 91 | - ? $value[0] |
|
| 90 | + $output[ $key ] = is_array($value) && count($value) === 1 |
|
| 91 | + ? $value[ 0 ] |
|
| 92 | 92 | : $value; |
| 93 | 93 | } |
| 94 | 94 | $output = !isset($output) || empty($output) ? '' : $output; |