-
Notifications
You must be signed in to change notification settings - Fork 6
/
Loader.php
55 lines (47 loc) · 1.45 KB
/
Loader.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
<?php
namespace LINE2Discord;
require_once 'Settings.php';
use LINE2Discord\Settings as Settings;
class Loader
{
private $_configure = "configure.json";
private $settings;
/**
* __construct
*
* @param Settings $settingsのポインタ
*
* @return void
*/
public function __construct(Settings &$settings)
{
$this->settings = &$settings;
}
/**
* configure.jsonから設定を読み出します。
*
* @return void
*/
public function loadConfigure()
{
// configure.jsonを読み込む
$json = $this->loadConfigureAsJson();
$settings->_token = $json["line"]["token"];
$settings->_secret = $json["line"]["secret"];
$settings->_groupId = $json["line"]["groupId"];
$settings->_maxFileSize = intval($json["system"]["maxFileSize"]);
$settings->_discordUrl = $json["discord"]["hookUrl"];
}
/**
* configure.jsonをJSON形式で読み込みます。
*
* @return array JSONデータ
*/
private function loadConfigureAsJson()
{
$json = file_get_contents($this->_configure);
$json = mb_convert_encoding($json, 'UTF8', 'ASCII,JIS,UTF-8,EUC-JP,SJIS-WIN');
return json_decode($json, true);
}
}
?>