public function testMapNative() { $strings = ["hello", "world", "!"]; $ucStrings = ["HELLO", "WORLD"]; $result = t::into([], t::comp(t::map('strtoupper'), t::take(2)), $strings); $this->assertEquals($ucStrings, $result); }
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; }