Source for file Venue.php

Documentation is available at Venue.php

  1. <?
  2.  
  3. /** Represents a venue.
  4.  *
  5.  * @package    php-lastfm-api
  6.  * @author  Felix Bruns <felixbruns@web.de>
  7.  * @version    1.0
  8.  */
  9. class Venue {
  10.     /** The venues name.
  11.      *
  12.      * @var string 
  13.      * @access private
  14.      */
  15.     private $name;
  16.  
  17.     /** The venues location.
  18.      *
  19.      * @var Location 
  20.      * @access private
  21.      */
  22.     private $location;
  23.  
  24.     /** The venues URL.
  25.      *
  26.      * @var string 
  27.      * @access private
  28.      */
  29.     private $url;
  30.  
  31.     /** Create a Venue object.
  32.      *
  33.      * @param string    $name        A venue name.
  34.      * @param Location    $location    A venue location.
  35.      * @param string    $url        A venue URL.
  36.      *
  37.      * @access public
  38.      */
  39.     public function __construct($nameLocation $location$url){
  40.         $this->name     $name;
  41.         $this->location $location;
  42.         $thus->url      $url;
  43.     }
  44.  
  45.     /** Returns the venues name.
  46.      *
  47.      * @return    string    A venue name.
  48.      * @access public
  49.      */
  50.     public function getName(){
  51.         return $this->name;
  52.     }
  53.  
  54.     /** Returns the venues location.
  55.      *
  56.      * @return    Location    A venue location.
  57.      * @access public
  58.      */
  59.     public function getLocation(){
  60.         return $this->location;
  61.     }
  62.  
  63.     /** Returns the venues URL.
  64.      *
  65.      * @return    string    A venue URL.
  66.      * @access public
  67.      */
  68.     public function getUrl(){
  69.         return $this->url;
  70.     }
  71.  
  72.     /** Get a list of upcoming events at this venue.
  73.      *
  74.      * @param    string    $venue    The venue id to fetch the events for. (Required)
  75.      * @return    array            An array of Event objects.
  76.      *
  77.      * @static
  78.      * @access    public
  79.      * @throws    Error
  80.      */
  81.     public static function getEvents($event){
  82.         $xml CallerFactory::getDefaultCaller()->call('venue.getEvents'array(
  83.             'event' => $event
  84.         ));
  85.  
  86.         $events array();
  87.  
  88.         foreach($xml->children(as $event){
  89.             $events[Event::fromSimpleXMLElement($event);
  90.         }
  91.  
  92.         return $events;
  93.     }
  94.  
  95.     /** Get a paginated list of all the events held at this venue in the past.
  96.      *
  97.      * @param    string    $venue    The id for the venue you would like to fetch event listings for. (Required)
  98.      * @param    integer    $limit    The maximum number of results to return. (Optional)
  99.      * @param    integer    $page    The page of results to return. (Optional)
  100.      * @return    PaginatedResult    A PaginatedResult object.
  101.      * @see        PaginatedResult
  102.      *
  103.      * @static
  104.      * @access    public
  105.      * @throws    Error
  106.      */
  107.     public static function getPastEvents($venue$limit null$page null){
  108.         $xml CallerFactory::getDefaultCaller()->call('venue.getPastEvents'array(
  109.             'venue' => $venue,
  110.             'limit' => $limit,
  111.             'page'  => $page
  112.         ));
  113.  
  114.         $events array();
  115.  
  116.         foreach($xml->children(as $event){
  117.             $events[Event::fromSimpleXMLElement($event);
  118.         }
  119.  
  120.         $perPage Util::toInteger($xml['perPage']);
  121.  
  122.         return new PaginatedResult(
  123.             Util::toInteger($xml['total']),
  124.             (Util::toInteger($xml['page']1$perPage,
  125.             $perPage,
  126.             $events
  127.         );
  128.     }
  129.  
  130.     /** Search for a venue by venue name .
  131.      *
  132.      * @param    string    $venue        The venue name you would like to search for. (Required)
  133.      * @param    integer    $limit        The number of results to fetch per page. Defaults to 50. (Optional)
  134.      * @param    integer    $page        The results page you would like to fetch. (Optional)
  135.      * @param    string    $country    Filter your results by country. Expressed as an ISO 3166-2 code. (Optional)
  136.      * @return    PaginatedResult        A PaginatedResult object.
  137.      * @see        PaginatedResult
  138.      *
  139.      * @static
  140.      * @access    public
  141.      * @throws    Error
  142.      */
  143.     public static function search($venue$limit null$page null$country null){
  144.         $xml CallerFactory::getDefaultCaller()->call('venue.search'array(
  145.             'venue'   => $venue,
  146.             'limit'   => $limit,
  147.             'page'    => $page,
  148.             'country' => $country
  149.         ));
  150.  
  151.         $venues array();
  152.  
  153.         foreach($xml->venuematches->children(as $venue){
  154.             $venues[Venue::fromSimpleXMLElement($venue);
  155.         }
  156.  
  157.         $opensearch $xml->children('http://a9.com/-/spec/opensearch/1.1/');
  158.  
  159.         return new PaginatedResult(
  160.             Util::toInteger($opensearch->totalResults),
  161.             Util::toInteger($opensearch->startIndex),
  162.             Util::toInteger($opensearch->itemsPerPage),
  163.             $venues
  164.         );
  165.     }
  166.  
  167.     /** Create a Venue object from a SimpleXMLElement.
  168.      *
  169.      * @param    SimpleXMLElement    $xml    A SimpleXMLElement.
  170.      * @return    Venue                        A Venue object.
  171.      *
  172.      * @static
  173.      * @access    public
  174.      * @internal
  175.      */
  176.     public static function fromSimpleXMLElement(SimpleXMLElement $xml){
  177.         return new Venue(
  178.             Util::toString($xml->name),
  179.             Location::fromSimpleXMLElement($xml->location),
  180.             Util::toString($xml->url)
  181.         );
  182.     }
  183. }
  184.  
  185. ?>

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