createFromJson() public static méthode

public static createFromJson ( $json )
Exemple #1
0
 /**
  * Factory method to create an instance and extract the data from the given JSON object
  *
  * @param   object     $json  The item JSON
  * @param   Location   $obj    An object or null to create it
  * @return  Location           The created instance
  */
 public static function createFromJson($json, Location $obj = null)
 {
     if (!is_object($obj)) {
         throw new \InvalidArgumentException('Argument must be an object');
     }
     if ($json->name) {
         $obj->name = html_entity_decode($json->name, null, 'UTF-8');
     }
     $obj->coordinate = Coordinate::createFromJson($json);
     return $obj;
 }