1: <?php
2: namespace duyplus\tmdbapi\classes\config;
3:
4: /**
5: * This class handles all the data you can get from the api Configuration
6: *
7: * @package TMDB_V3_API_PHP
8: * @author Alvaro Octal
9: * @version 0.7
10: * @date 20/01/2015
11: * @updated 31/12/2024
12: * @link https://github.com/duyplus/tmdbapi
13: * @copyright Licensed under BSD (http://www.opensource.org/licenses/bsd-license.php)
14: */
15:
16: class Configuration
17: {
18:
19: //------------------------------------------------------------------------------
20: // Class Variables
21: //------------------------------------------------------------------------------
22:
23: private $apikey = '';
24: private $lang = 'en';
25: private $timezone = 'Europe/Berlin';
26: private $adult = false;
27: private $debug = false;
28:
29: /**
30: * Data Return Configuration - Manipulate if you want to tune your results
31: */
32: private $appender = [
33: 'movie' => array('account_states', 'alternative_titles', 'credits', 'images', 'keywords', 'release_dates', 'videos', 'translations', 'similar', 'reviews', 'lists', 'changes', 'rating'),
34: 'tvshow' => array('account_states', 'alternative_titles', 'changes', 'content_rating', 'credits', 'external_ids', 'images', 'keywords', 'rating', 'similar', 'translations', 'videos'),
35: 'season' => array('changes', 'account_states', 'credits', 'external_ids', 'images', 'videos'),
36: 'episode' => array('changes', 'account_states', 'credits', 'external_ids', 'images', 'rating', 'videos'),
37: 'person' => array('movie_credits', 'tv_credits', 'combined_credits', 'external_ids', 'images', 'tagged_images', 'changes'),
38: 'collection' => array('images'),
39: 'company' => array('movies'),
40: ];
41:
42: //------------------------------------------------------------------------------
43: // Constructor
44: //------------------------------------------------------------------------------
45:
46: /**
47: * Construct Class
48: *
49: * @param array $cnf An array with the configuration data
50: */
51: public function __construct($cnf = null)
52: {
53: // Check if config is given and use default if not
54: // Note: There is no API Key inside the default conf
55: if (!isset($cnf)) {
56: require_once __DIR__ . '/../../configuration/Default.php';
57: }
58: $this->setAPIKey(isset($cnf['apikey']) ? $cnf['apikey'] : null);
59: $this->setLang(isset($cnf['lang']) ? $cnf['lang'] : 'en');
60: $this->setTimeZone(isset($cnf['timezone']) ? $cnf['timezone'] : 'UTC');
61: $this->setAdult(isset($cnf['adult']) ? (bool) $cnf['adult'] : false);
62: $this->setDebug(isset($cnf['debug']) ? (bool) $cnf['debug'] : false);
63: }
64:
65:
66: //------------------------------------------------------------------------------
67: // Set Variables
68: //------------------------------------------------------------------------------
69:
70: /**
71: * Set the API Key
72: *
73: * @param string $apikey
74: */
75: public function setAPIKey($apikey)
76: {
77: $this->apikey = $apikey;
78: }
79:
80: /**
81: * Set the language code
82: *
83: * @param string $lang
84: */
85: public function setLang($lang)
86: {
87: $this->lang = $lang;
88: }
89:
90: /**
91: * Set the timezone
92: *
93: * @param string $timezone
94: */
95: public function setTimeZone($timezone)
96: {
97: $this->timezone = $timezone;
98: }
99:
100: /**
101: * Set the adult flag
102: *
103: * @param boolean $adult
104: */
105: public function setAdult($adult)
106: {
107: $this->adult = $adult;
108: }
109:
110: /**
111: * Set the debug flag
112: *
113: * @param boolean $debug
114: */
115: public function setDebug($debug)
116: {
117: $this->debug = $debug;
118: }
119:
120: /**
121: * Set an appender for a special type
122: *
123: * @param array $appender
124: * @param string $type
125: */
126: public function setAppender($appender, $type)
127: {
128: $this->appender[$type] = $appender;
129: }
130:
131: //------------------------------------------------------------------------------
132: // Get Variables
133: //------------------------------------------------------------------------------
134:
135: /**
136: * Get the API Key
137: *
138: * @return string
139: */
140: public function getAPIKey()
141: {
142: return $this->apikey;
143: }
144:
145: /**
146: * Get the language code
147: *
148: * @return string
149: */
150: public function getLang()
151: {
152: return $this->lang;
153: }
154:
155: /**
156: * Get the timezone
157: *
158: * @return string
159: */
160: public function getTimeZone()
161: {
162: return $this->timezone;
163: }
164:
165: /**
166: * Get the adult string
167: *
168: * @return string
169: */
170: public function getAdult()
171: {
172: return ($this->adult) ? 'true' : 'false';
173: }
174:
175: /**
176: * Get the debug flag
177: *
178: * @return boolean
179: */
180: public function getDebug()
181: {
182: return $this->debug;
183: }
184:
185: /**
186: * Get the appender array for a type
187: *
188: * @return array
189: */
190: public function getAppender($type)
191: {
192: return $this->appender[$type];
193: }
194: }
195:
196: ?>