Esempio n. 1
0
 public function testIntervalsToArray()
 {
     $array = array('Age' => array('choices' => array('(0;14)', '(15;19>', '<20;30)', '<30;45>')));
     $attr = new Attribute();
     $attr->setName('Age');
     $attr->addInterval('(0;14)');
     $attr->addInterval('(15;19>');
     $attr->addInterval('<20;30)');
     $attr->addInterval('<30;45>');
     $this->assertEquals($array, $attr->toArray());
 }
Esempio n. 2
0
 protected function parseAttributes()
 {
     $attributes = array();
     foreach ($this->XPath->evaluate('//dd:DataDescription/Dictionary[@default="true"]/Field') as $f) {
         $attribute = new Attribute();
         foreach ($f->childNodes as $n) {
             if ($n->nodeName == "Name") {
                 $attribute->setName($n->nodeValue);
             }
             if ($n->nodeName == "Category") {
                 $attribute->addCategory($n->nodeValue);
             }
             if ($n->nodeName == "Interval") {
                 $closure = $n->getAttribute('closure');
                 $interval = substr($closure, 0, 4) === 'open' ? '(' : '<';
                 $interval .= $n->getAttribute('leftMargin') . ';' . $n->getAttribute('rightMargin');
                 $interval .= substr($closure, -4, 4) === 'Open' ? ')' : '>';
                 $attribute->addInterval($interval);
             }
         }
         array_push($attributes, $attribute);
     }
     return $attributes;
 }