Exemple #1
0
 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);
 }
Exemple #2
0
 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;
 }