Completed
Pull Request — master (#267)
by
unknown
11:00
created

Config::getInstance()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 0
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
1
<?php
2
namespace QiniuRtc;
3
4
final class Config
5
{
6
    const SDK_VERSION = '1.0.0';
7
    const SDK_USER_AGENT = 'Rtc-sdk-php';
8
9
    public $USE_HTTPS = false;
10
11
    public $RTCAPI_HOST = 'http://rtc.qiniuapi.com';
12
    public $RTCAPI_VERSION = 'v3';   //连麦版本号
13
14
    protected static $_instance = null;
15
16
    protected function __construct()
17
    {
18
    }
19
20
    protected function __clone()
21
    {
22
    }
23
24
    public static function getInstance()
25
    {
26
        if (!(self::$_instance instanceof self)) {
27
            self::$_instance = new self();
28
        }
29
        return self::$_instance;
30
    }
31
32
    public function __get($property)
33
    {
34
        if (property_exists(self::getInstance(), $property)) {
35
            return self::getInstance()->$property;
36
        } else {
37
            return null;
38
        }
39
    }
40
41
    public function __set($property, $value)
42
    {
43
        if (property_exists(self::getInstance(), $property)) {
44
            self::getInstance()->$property = $value;
45
        }
46
        return self::getInstance();
47
    }
48
}
49