Source for file Session.php

Documentation is available at Session.php

  1. <?
  2.  
  3. /** Stores information of a last.fm session.
  4.  *
  5.  * @package    php-lastfm-api
  6.  * @author  Felix Bruns <felixbruns@web.de>
  7.  * @version    1.0
  8.  */
  9. class Session {
  10.     /** The session username.
  11.      *
  12.      * @var string 
  13.      * @access    private
  14.      */
  15.     private $name;
  16.  
  17.     /** The session key.
  18.      *
  19.      * @var string 
  20.      * @access    private
  21.      */
  22.     private $key;
  23.  
  24.     /** Indicates if this user is a subscriber.
  25.      *
  26.      * @var boolean 
  27.      * @access    private
  28.      */
  29.     private $subscriber;
  30.  
  31.     /** Create a Session object.
  32.      *
  33.      * @param string    $name        Session username.
  34.      * @param string    $key        Session key.
  35.      * @param boolean    $subscriber    User is subscriber.
  36.      *
  37.      * @access    public
  38.      */
  39.     public function __construct($name$key$subscriber){
  40.         $this->name       $name;
  41.         $this->key        $key;
  42.         $this->subscriber $subscriber;
  43.     }
  44.  
  45.     /** Returns the session username.
  46.      *
  47.      * @return string    A last.fm username.
  48.      * @access    public
  49.      */
  50.     public function getName(){
  51.         return $this->name;
  52.     }
  53.  
  54.     /** Returns the session key.
  55.      *
  56.      * @return string    A session key.
  57.      * @access    public
  58.      */
  59.     public function getKey(){
  60.         return $this->key;
  61.     }
  62.  
  63.     /** Returns if the user is a subscriber.
  64.      *
  65.      * @return boolean    true if the user is a subscriber, otherwise false.
  66.      * @access    public
  67.      */
  68.     public function isSubscriber(){
  69.         return $this->subscriber;
  70.     }
  71.  
  72.     /** Create a Session object from a SimpleXMLElement.
  73.      *
  74.      * @param    SimpleXMLElement    $xml    A SimpleXMLElement.
  75.      * @return    Session                        A Session object.
  76.      *
  77.      * @static
  78.      * @access    public
  79.      * @internal
  80.      */
  81.     public static function fromSimpleXMLElement(SimpleXMLElement $xml){
  82.         return new Session(
  83.             Util::toString($xml->name),
  84.             Util::toString($xml->key),
  85.             Util::toBoolean($xml->subscriber)
  86.         );
  87.     }
  88. }
  89.  
  90. ?>

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