예제 #1
0
 public function testCategoriesToArray()
 {
     $array = array('District' => array('choices' => array('Praha', 'Brno')));
     $attr = new Attribute();
     $attr->setName('District');
     $attr->addCategory('Praha');
     $attr->addCategory('Brno');
     $this->assertEquals($array, $attr->toArray());
 }
예제 #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;
 }