1:   2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14:  15:  16:  17:  18:  19:  20:  21:  22:  23:  24:  25:  26:  27:  28:  29:  30:  31:  32:  33:  34:  35:  36:  37:  38:  39:  40:  41:  42:  43:  44:  45:  46:  47:  48:  49:  50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 
<?php
/**
 *  This class handles the user Configuration
 *
 *  @package TMDB-V3-PHP-API
 *  @author Deso85 | <a href="https://twitter.com/cizero">Twitter</a>
 *  @version 0.1
 *  @date 02/04/2016
 *  @link https://github.com/Alvaroctal/TMDB-PHP-API
 *  @copyright Licensed under BSD (http://www.opensource.org/licenses/bsd-license.php)
 */

class Configuration {

    //------------------------------------------------------------------------------
    // Class Variables
    //------------------------------------------------------------------------------
    
    private $apikey = '';
    private $lang = 'en';
    private $timezone = 'Europe/London';
    private $adult = false;
    private $debug = false;
    private $appender;
    
    //------------------------------------------------------------------------------
    // Constructor
    //------------------------------------------------------------------------------
    
    /**
     *  Construct Class
     *
     *  @param array $cnf An array with the configuration data
     */
    public function __construct($cnf) {
        // Check if config is given and use default if not
        // Note: There is no API Key inside the default conf
        if(!isset($cnf)) {
            require_once( dirname(__FILE__) . "/../../../configuration/default.php");
        }
        
        $this->setAPIKey($cnf['apikey']);
        $this->setLang($cnf['lang']);
        $this->setTimeZone('timezone');
        $this->setAdult($cnf['adult']);
        $this->setDebug($cnf['debug']);
        
        foreach($cnf['appender'] as $type => $appender) {
            $this->setAppender($appender, $type);
        }
    }
    
    //------------------------------------------------------------------------------
    // Set Variables
    //------------------------------------------------------------------------------
    
    /**
     *  Set the API Key
     *
     *  @param string $apikey
     */
    public function setAPIKey($apikey){
        $this->apikey = $apikey;
    }
    
    /**
     *  Set the language code
     *
     *  @param string $lang
     */
    public function setLang($lang){
        $this->lang = $lang;
    }
    
    /**
     *  Set the timezone
     *
     *  @param string $timezone
     */
    public function setTimeZone($timezone){
        $this->timezone = $timezone;
    }
    
    /**
     *  Set the adult flag
     *
     *  @param boolean $adult
     */
    public function setAdult($adult){
        $this->adult = $adult;
    }
    
    /**
     *  Set the debug flag
     *
     *  @param boolean $debug
     */
    public function setDebug($debug){
        $this->debug = $debug;
    }
    
    /**
     *  Set an appender for a special type
     *
     *  @param array $appender
     *  @param string $type
     */
    public function setAppender($appender, $type){
        $this->appender[$type] = $appender;
    }
    
    //------------------------------------------------------------------------------
    // Get Variables
    //------------------------------------------------------------------------------
    
    /**
     *  Get the API Key
     *
     *  @return string
     */
    public function getAPIKey(){
        return $this->apikey;
    }
    
    /**
     *  Get the language code
     *
     *  @return string
     */
    public function getLang(){
        return $this->lang;
    }
    
    /**
     *  Get the timezone
     *
     *  @return string
     */
    public function getTimeZone(){
        return $this->timezone;
    }
    
    /**
     *  Get the adult string
     *
     *  @return string
     */
    public function getAdult(){
        return ($this->adult) ? 'true' : 'false';
    }
    
    /**
     *  Get the debug flag
     *
     *  @return boolean
     */
    public function getDebug(){
        return $this->debug;
    }
    
    /**
     *  Get the appender array for a type
     *
     *  @return array
     */
    public function getAppender($type){
        return $this->appender[$type];
    }
}

?>