Beispiel #1
0
 /**
  * @return VCardEmail|null
  */
 public static function createFromAttribute(VCardElementAttribute $attr)
 {
     $types = array_map('strtoupper', $attr->getParamValues('TYPE'));
     $typeMap = array_flip($types);
     if (isset($typeMap['x400'])) {
         // X.400 is not supported
         return null;
     }
     $item = new VCardEmail();
     $item->value = $attr->getValue();
     $item->types = $types;
     return $item;
 }
Beispiel #2
0
 /**
  * @return VCardAddress|null
  */
 public static function createFromAttribute(VCardElementAttribute $attr)
 {
     $str = $attr->getValue();
     $parts = explode(';', $str);
     if (count($parts) < 7) {
         return null;
     }
     $item = new VCardAddress();
     for ($i = 0; $i < 7; $i++) {
         $s = trim($parts[$i]);
         if ($s === '') {
             continue;
         }
         if ($i === 0) {
             $item->pobox = $s;
         } elseif ($i === 1) {
             $item->ext = $s;
         } elseif ($i === 2) {
             $item->street = $s;
         } elseif ($i === 3) {
             $item->locality = $s;
         } elseif ($i === 4) {
             $item->region = $s;
         } elseif ($i === 5) {
             $item->code = $s;
         } elseif ($i === 6) {
             $item->country = $s;
         }
     }
     return $item;
 }
Beispiel #3
0
 /**
  * @return VCardFile|null
  */
 public static function createFromAttribute(VCardElementAttribute $attr)
 {
     $item = new VCardFile();
     $item->value = $attr->getValue();
     $item->valueType = strtoupper($attr->getFirstParamValue('VALUE', ''));
     $item->type = strtoupper($attr->getFirstParamValue('TYPE', ''));
     $item->encoding = strtoupper($attr->getFirstParamValue('ENCODING', ''));
     return $item;
 }
Beispiel #4
0
 /**
  * @return VCardPhone|null
  */
 public static function createFromAttribute(VCardElementAttribute $attr)
 {
     $item = new VCardPhone();
     $item->value = $attr->getValue();
     $item->valueType = strtoupper($attr->getFirstParamValue('VALUE', 'text'));
     $item->types = array_map('strtoupper', $attr->getParamValues('TYPE'));
     return $item;
 }