Example #1
0
 /**
  * Creates a stuff with attributes
  *
  * @param $owner Charac The stuff owner
  * @param $name string Name of the stuff
  * @param $rarity integer Rarity of the stuff
  * @param $level integer Level of the stuff
  * @param $weight integer Weight of the stuff
  * @return Stuff The newly created stuff
  */
 public static function withAttributes($owner, $name, $rarity, $level, $weight)
 {
     $instance = new self();
     $instance->setOwner($owner);
     $instance->setName($name);
     $instance->setRarity($rarity);
     $instance->setLevel($level);
     $instance->setWeight($weight);
     return $instance;
 }
Example #2
0
 /**
  * @param  array $data
  * @return Group
  */
 public static function factory(array $data)
 {
     $group = new self();
     $group->setId($data['id']);
     $group->setOwner(Identity::parseJID($data['owner']));
     $creation = new DateTime();
     $creation->setTimestamp((int) $data['creation']);
     $group->setCreation($creation);
     $group->setSubject($data['subject']);
     return $group;
 }
Example #3
0
 /**
  * @see CultureFeed_Cdb_IElement::parseFromCdbXml(SimpleXMLElement $xmlElement)
  * @return CultureFeed_Cdb_Item_Actor
  */
 public static function parseFromCdbXml(SimpleXMLElement $xmlElement)
 {
     if (empty($xmlElement->categories)) {
         throw new CultureFeed_Cdb_ParseException('Categories missing for actor element');
     }
     if (empty($xmlElement->actordetails)) {
         throw new CultureFeed_Cdb_ParseException('Actordetails missing for actor element');
     }
     $actor = new self();
     $actor_attributes = $xmlElement->attributes();
     if (isset($actor_attributes['cdbid'])) {
         $actor->setCdbId((string) $actor_attributes['cdbid']);
     }
     if (isset($actor_attributes['externalid'])) {
         $actor->setExternalId((string) $actor_attributes['externalid']);
     }
     if (isset($actor_attributes['availablefrom'])) {
         $actor->setAvailableFrom((string) $actor_attributes['availablefrom']);
     }
     if (isset($actor_attributes['availableto'])) {
         $actor->setAvailableTo((string) $actor_attributes['availableto']);
     }
     if (isset($actor_attributes['createdby'])) {
         $actor->setCreatedBy((string) $actor_attributes['createdby']);
     }
     if (isset($actor_attributes['creationdate'])) {
         $actor->setCreationDate((string) $actor_attributes['creationdate']);
     }
     if (isset($actor_attributes['lastupdated'])) {
         $actor->setLastUpdated((string) $actor_attributes['lastupdated']);
     }
     if (isset($actor_attributes['lastupdatedby'])) {
         $actor->setLastUpdatedBy((string) $actor_attributes['lastupdatedby']);
     }
     if (isset($actor_attributes['owner'])) {
         $actor->setOwner((string) $actor_attributes['owner']);
     }
     $actor->setDetails(CultureFeed_Cdb_Data_ActorDetailList::parseFromCdbXml($xmlElement->actordetails));
     // Set categories
     $actor->setCategories(CultureFeed_Cdb_Data_CategoryList::parseFromCdbXml($xmlElement->categories));
     // Set contact information.
     if (!empty($xmlElement->contactinfo)) {
         $actor->setContactInfo(CultureFeed_Cdb_Data_ContactInfo::parseFromCdbXml($xmlElement->contactinfo));
     }
     // Set the keywords.
     self::parseKeywords($xmlElement, $actor);
     // Set the weekscheme.
     if (!empty($xmlElement->weekscheme)) {
         $actor->setWeekScheme(CultureFeed_Cdb_Data_Calendar_Weekscheme::parseFromCdbXml($xmlElement->weekscheme));
     }
     return $actor;
 }
Example #4
0
 /**
  * @param \DOMElement $element
  *
  * @throws \InvalidArgumentException
  * @return self
  *
  * @todo define exception message
  */
 public static function fromXml(\DOMElement $element)
 {
     $xpath = new \DOMXPath($element->ownerDocument);
     $xpath->registerNamespace('D', 'DAV:');
     $xLockType = $xpath->query('D:locktype/*', $element);
     $xLockScope = $xpath->query('D:lockscope/*', $element);
     if ($xLockType->length == 0 || $xLockScope->length == 0) {
         throw new \InvalidArgumentException();
     }
     $result = new self($xLockScope->item(0)->localName, $xLockType->item(0)->localName);
     if ($depth = $xpath->evaluate('string(D:depth)', $element)) {
         $result->setDepth(DepthHeader::parse($depth));
     }
     if ($timeout = $xpath->evaluate('string(D:timeout)', $element)) {
         $result->setTimeout($timeout);
     }
     $xOwner = $xpath->query('D:owner', $element);
     if ($xOwner->length) {
         $result->setOwner(trim($xOwner->item(0)->textContent));
     }
     $xLockToken = $xpath->query('D:locktoken', $element);
     if ($xLockToken->length) {
         $result->setToken(trim($xLockToken->item(0)->textContent));
     }
     return $result;
 }