-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.php
56 lines (46 loc) · 1.34 KB
/
config.php
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
<?php
require __DIR__.'/vendor/autoload.php';
use Karriere\JsonDecoder\JsonDecoder;
class AppConfiguration{
public $title;
public $code;
public $copyright;
public $webmaster;
}
class OwnerConfiguration{
public $name;
public $address;
public $contact_number;
}
class ApiConfiguration{
public $api_key;
public $api_endpoint;
}
class Configuration{
public $file_name;
public $data;
function __construct($file_name=null){
$this->file_name=$file_name;
if($this->file_name !=null){
$path="config/".$this->file_name;
$f=fopen($path,"r");
$text=fread($f,filesize($path));
fclose($f);
$this->data=json_decode($text);
}
}
function get_app_config():AppConfiguration{
$jsonDecoder=new JsonDecoder();
//echo $this->data->app;
return $jsonDecoder->decode(json_encode($this->data->app),AppConfiguration::class);
}
function get_owner_config():OwnerConfiguration{
$jsonDecoder=new JsonDecoder();
return $jsonDecoder->decode(json_encode($this->data->owner),OwnerConfiguration::class);
}
function get_api_config():ApiConfiguration{
$jsonDecoder=new JsonDecoder();
return $jsonDecoder->decode(json_encode($this->data->api),ApiConfiguration::class);
}
}
?>