diff --git a/src/Convert.php b/src/Convert.php deleted file mode 100644 index b9caa97..0000000 --- a/src/Convert.php +++ /dev/null @@ -1,121 +0,0 @@ - [ - * 'child' => [ - * ['name' => 'Wendy Darling'], - * ['name' => 'John Darling'], - * ['name' => 'Michael Darling'], - * ], - * ]] - * - * Output XML = - * - * Wendy Darling - * John Darling - * Michael Darling - * - * - * @static - * @param array $array array to convert into XML - * @return string generated XML - */ - public static function arrayToXML($array, $format = false, $level = 0) - { - $xml = ''; - - if (is_array($array)) - { - foreach ($array as $node => $value) - { - // Checks if the value is an array - if (is_array($value)) - { - foreach ($value as $node2 => $value2) - { - if (is_array($value2)) - { - // Nest the value if the node is an integer - $new_value = (is_int($node2) ? $value2 : [$node2 => $value2]); - - $xml .= ($format ? str_repeat("\t", $level) : ''); - $xml .= '<' . $node . '>' . ($format ? "\n" : ''); - $xml .= self::arrayToXML($new_value, $format, $level + 1); - $xml .= ($format ? str_repeat("\t", $level) : ''); - $xml .= '' . ($format ? "\n" : ''); - } - else - { - if (is_int($node2)) - { - $node2 = $node; - } - - // Checks for special characters - if (htmlspecialchars($value2) != $value2) - { - $xml .= ($format ? str_repeat("\t", $level) : ''); - $xml .= '<' . $node2 . '>' . ($format ? "\n" : ''); - } - else - { - $xml .= ($format ? str_repeat("\t", $level) : ''); - $xml .= '<' . $node2 . '>' . $value2 . '' . ($format ? "\n" : ''); - } - } - } - } - else - { - // Checks for special characters - if (htmlspecialchars($value) != $value) - { - $xml .= ($format ? str_repeat("\t", $level) : ''); - $xml .= '<' . $node . '>' . ($format ? "\n" : ''); - } - else - { - $xml .= ($format ? str_repeat("\t", $level) : ''); - $xml .= '<' . $node . '>' . $value . '' . ($format ? "\n" : ''); - } - } - } - } - - return $xml; - } - - // }}} -} - diff --git a/tests/Pickles/ConvertTest.php b/tests/Pickles/ConvertTest.php deleted file mode 100644 index 36314a6..0000000 --- a/tests/Pickles/ConvertTest.php +++ /dev/null @@ -1,27 +0,0 @@ -assertEquals(Pickles\Convert::arrayToXML($a, $b), $c); - } - - public function providerArrayToXML() - { - return [ - ['foo', false, ''], - [['foo', 'bar'], false, '<0>foo<1>bar'], - [['foo', 'bar'], true, "<0>foo\n<1>bar\n"], - [['foo' => 'bar'], false, 'bar'], - [['foo' => 'b & r'], false, ''], - [['children' => ['child' => ['foo', 'bar']]], false, 'foobar'], - [['children' => ['child' => ['foo & bar']]], false, ''], - [['children' => ['child' => ['foo', 'bar']]], true, "\n\tfoo\n\tbar\n\n"], - ]; - } -} -