public static function parse($xml) { /* @var $xml \DOMElement */ $element = [$xml->tagName]; if ($xml->hasAttributes()) { $xf = t::comp(t::map(t::value()), t::map(function (\DOMAttr $attr) { return [$attr->name, $attr->value]; })); $element[] = t::intoAssoc([], $xf, $xml->attributes); } if ($xml->hasChildNodes()) { $xf = t::comp(t::map(t::value()), t::map(['\\Phonon\\Xml\\XmlParser', 'parse'])); $element[] = t::into([], $xf, $xml->childNodes); } return $element; }
public function testMapStringInto() { $expected = "Hello"; $actual = t::into("", t::map(t::identity()), ["H", "e", "l", "l", "o"]); $this->assertEquals($expected, $actual); }