createFromXml() public static method

Factory method to create an instance of Coordinate and extract the data from the given xml.
public static createFromXml ( SimpleXMLElement $xml ) : Coordinate
$xml SimpleXMLElement The item xml
return Coordinate The created instance
Beispiel #1
0
 /**
  * Factory method to create an instance and extract the data from the given xml
  *
  * @param   \SimpleXMLElement   $xml    The item xml
  * @param   Location            $obj    An object or null to create it
  * @return  Location            The created instance
  */
 public static function createFromXml(\SimpleXMLElement $xml, Location $obj = null)
 {
     if (!is_object($obj)) {
         throw new \InvalidArgumentException('Argument must be an object');
     }
     if ($xml['name']) {
         $obj->name = (string) $xml['name'];
     }
     if ($xml['score']) {
         $obj->score = (string) $xml['score'];
     }
     $obj->coordinate = Coordinate::createFromXml($xml);
     return $obj;
 }