Source for file Location.php

Documentation is available at Location.php

  1. <?
  2.  
  3. /** Represents a geographical location (address, coordinate, timezone).
  4.  *
  5.  * @package    php-lastfm-api
  6.  * @author  Felix Bruns <felixbruns@web.de>
  7.  * @version    1.0
  8.  */
  9. class Location {
  10.     /** The locations city.
  11.      *
  12.      * @var string 
  13.      * @access    private
  14.      */
  15.     private $city;
  16.  
  17.     /** The locations country.
  18.      *
  19.      * @var string 
  20.      * @access    private
  21.      */
  22.     private $country;
  23.  
  24.     /** The locations street.
  25.      *
  26.      * @var string 
  27.      * @access    private
  28.      */
  29.     private $street;
  30.  
  31.     /** The locations postal code.
  32.      *
  33.      * @var integer 
  34.      * @access    private
  35.      */
  36.     private $postalCode;
  37.  
  38.     /** The locations geographical coordinate.
  39.      *
  40.      * @var Point 
  41.      * @access    private
  42.      */
  43.     private $point;
  44.  
  45.     /** The locations timezone.
  46.      *
  47.      * @var string 
  48.      * @access    private
  49.      */
  50.     private $timezone;
  51.  
  52.     /** Create a Location object.
  53.      *
  54.      * @param string    $city        A city name.
  55.       * @param string    $country    An ISO 3166-1 country code.
  56.       * @param string    $street        A street name.
  57.       * @param integer    $postalCode    A postal code.
  58.       * @param Point        $point        A Point object.
  59.       * @param string    $timezone    A timezone string.
  60.      *
  61.      * @access    public
  62.      */
  63.     public function __construct($city$country$street$postalCode,
  64.                                 Point $point$timezone){
  65.         $this->city       $city;
  66.         $this->country    $country;
  67.         $this->street     $street;
  68.         $this->postalCode $postalCode;
  69.         $this->point      $point;
  70.         $this->timezone   $timezone;
  71.     }
  72.  
  73.     /** Returns the locations city.
  74.      *
  75.      * @return    string    A city name.
  76.      * @access    public
  77.      */
  78.     public function getCity(){
  79.         return $this->city;
  80.     }
  81.  
  82.     /** Returns the locations country.
  83.      *
  84.      * @return    string    An ISO 3166-1 country code.
  85.      * @access    public
  86.      */
  87.     public function getCountry(){
  88.         return $this->country;
  89.     }
  90.  
  91.     /** Returns the locations street.
  92.      *
  93.      * @return    string    A street name.
  94.      * @access    public
  95.      */
  96.     public function getStreet(){
  97.         return $this->street;
  98.     }
  99.  
  100.     /** Returns the locations postal code.
  101.      *
  102.      * @return    integer    A postal code.
  103.      * @access    public
  104.      */
  105.     public function getPostalCode(){
  106.         return $this->postalCode;
  107.     }
  108.  
  109.     /** Returns the locations geographical point.
  110.      *
  111.      * @return    string    A Point object.
  112.      * @access    public
  113.      */
  114.     public function getPoint(){
  115.         return $this->point;
  116.     }
  117.  
  118.     /** Returns the locations timezone.
  119.      *
  120.      * @return    string    A timezone string.
  121.      * @access    public
  122.      */
  123.     public function getTimezone(){
  124.         return $this->timezone;
  125.     }
  126.  
  127.     /** Create a Location object from a SimpleXMLElement.
  128.      *
  129.      * @param    SimpleXMLElement    $xml    A SimpleXMLElement.
  130.      * @return    Location                    A Location object.
  131.      *
  132.      * @static
  133.      * @access    public
  134.      * @internal
  135.      */
  136.     public static function fromSimpleXMLElement(SimpleXMLElement $xml){
  137.         $geo $xml->children('http://www.w3.org/2003/01/geo/wgs84_pos#');
  138.  
  139.         return new Location(
  140.             Util::toString($xml->city),
  141.             Util::toString($xml->country),
  142.             Util::toString($xml->street),
  143.             Util::toString($xml->postalcode),
  144.             ($geo->point)?new Point(
  145.                 Util::toFloat($geo->point->lat),
  146.                 Util::toFloat($geo->point->long)
  147.             ):null,
  148.             Util::toString($xml->timezome)
  149.         );
  150.     }
  151. }
  152.  
  153. ?>

Documentation generated on Mon, 22 Dec 2008 16:57:39 +0100 by phpDocumentor 1.4.1