You are here

class InstagramConf in Drupagram 7

Same name and namespace in other branches
  1. 6 drupagram.lib.php \InstagramConf

Class InstagramConf

Singleton which stores common configuration

Hierarchy

Expanded class hierarchy of InstagramConf

See also

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

File

./drupagram.lib.php, line 14
Classes to implement the full Instagram API

View source
class InstagramConf {
  private static $instance;
  private $attributes = array(
    'apibase' => 'https://api.instagram.com',
    'apiurl' => 'https://api.instagram.com/v1',
    '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
InstagramConf::$attributes private property
InstagramConf::$instance private static property
InstagramConf::get public function Generic getter
InstagramConf::instance public static function
InstagramConf::set public function Generic setter
InstagramConf::__construct private function