-
Notifications
You must be signed in to change notification settings - Fork 3
/
BinanceBotSettings.class.php
62 lines (52 loc) · 1.18 KB
/
BinanceBotSettings.class.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
57
58
59
60
61
62
<?php
namespace BinanceBot;
class BinanceBotSettings
{
private static $instance;
private $data = array();
private $configFile = "config.json";
private $timeLoaded = 0;
private $lastCacheClear = 0;
private function __construct()
{
$this->load();
}
private function load()
{
$this->lastCacheClear = time();
$this->data = json_decode( file_get_contents( $this->configFile ), true );
$this->timeloaded = filemtime( $this->configFile );
}
private function reload()
{
clearstatcache();
if($this->timeloaded < filemtime( $this->configFile )) {
print("Settings change detected... \n");
$this->load();
}
}
public function update()
{
$this->load();
}
public function __get( $variable )
{
$this->reload();
if( isset( $this->data[ $variable ] ) )
{
return $this->data[ $variable ];
}
else
{
print "Unknown variable: $variable\n";
}
}
public static function getInstance()
{
if ( !isset( self::$instance) )
{
self::$instance = new BinanceBotSettings();
}
return self::$instance;
}
}