exists() public method

public exists ( string $name, string $ns = null, array $attrs = [] ) : JAXLXml | boolean
$name string
$ns string
$attrs array
return JAXLXml | boolean
Exemplo n.º 1
0
 public function __set($prop, $val)
 {
     switch ($prop) {
         // access to jaxl xml properties
         case 'name':
         case 'ns':
         case 'text':
         case 'attrs':
         case 'children':
             return $this->xml->{$prop} = $val;
             break;
             // access to common xml attributes
         // access to common xml attributes
         case 'to':
         case 'from':
         case 'id':
         case 'type':
             $this->xml->attrs[$prop] = $val;
             return true;
             break;
             // access to parts of common xml attributes
         // access to parts of common xml attributes
         case 'to_node':
         case 'to_domain':
         case 'to_resource':
         case 'from_node':
         case 'from_domain':
         case 'from_resource':
             list($attr, $key) = explode('_', $prop);
             $val1 = isset($this->xml->attrs[$attr]) ? $this->xml->attrs[$attr] : null;
             if (!$val1) {
                 $val1 = '';
             }
             $val1 = new XMPPJid($val1);
             $val1->{$key} = $val;
             $this->xml->attrs[$attr] = $val1->to_string();
             return true;
             break;
             // access to first child element text
         // access to first child element text
         case 'status':
         case 'show':
         case 'priority':
         case 'body':
         case 'thread':
         case 'subject':
             $val1 = $this->xml->exists($prop);
             if (!$val1) {
                 $this->xml->c($prop)->t($val)->up();
             } else {
                 $this->xml->update($prop, $val1->ns, $val1->attrs, $val);
             }
             return true;
             break;
         default:
             return null;
             break;
     }
 }