You are here

class TwitterConf in Twitter 6.3

Class TwitterConfig

Singleton which stores common configuration

Hierarchy

Expanded class hierarchy of TwitterConf

See also

http://php.net/manual/en/language.oop5.patterns.php

File

./twitter.lib.php, line 13
Classes to implement the full Twitter API

View source
class TwitterConf {
  private static $instance;
  private $attributes = array(
    'host' => 'twitter.com',
    'api' => 'api.twitter.com',
    'search' => 'search.twitter.com',
    'tiny_url' => 'tinyurl.com',
  );
  private function __construct() {
  }
  public static function instance() {
    if (!isset(self::$instance)) {
      $className = __CLASS__;
      self::$instance = new $className();
    }
    return self::$instance;
  }

  /**
   * Generic getter
   *
   * @param $attribute
   *   string attribute name to return
   * @return
   *   mixed value or NULL
   */
  public function get($attribute) {
    if (array_key_exists($attribute, $this->attributes)) {
      return $this->attributes[$attribute];
    }
  }

  /**
   * Generic setter
   * @param $attribute
   *   string attribute name to be set
   * @param $value
   *   mixed value
   */
  public function set($attribute, $value) {
    if (array_key_exists($attribute, $this->attributes)) {
      $this->attributes[$attribute] = $value;
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
TwitterConf::$attributes private property
TwitterConf::$instance private static property
TwitterConf::get public function Generic getter
TwitterConf::instance public static function
TwitterConf::set public function Generic setter
TwitterConf::__construct private function