-
Notifications
You must be signed in to change notification settings - Fork 6
/
Dy.php
59 lines (52 loc) · 1.48 KB
/
Dy.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
<?php
use ByteDance\Kernel\DataArray;
/**
* Class Dy
* @package ByteDance
*
* @method \ByteDance\Oauth Oauth($options = []) static 扫码授权
* @method \ByteDance\Poi Poi($options = []) static 商铺接入
* @method \ByteDance\User User($options = []) static 用户操作
* @method \ByteDance\Video Video($options = []) static 视频操作
* @method \ByteDance\Comment Comment($options = []) static 用户评论
* @method \ByteDance\Toutiao Toutiao($options = []) static 头条操作
* @method \ByteDance\Othe Othe($options = []) static 其它操作
*/
class Dy
{
/**
* 静态配置
*/
private static $config;
/**
* 设置及获取参数
* @param array $option
* @return array
*/
public static function config($option = null)
{
if (is_array($option)) {
self::$config = new DataArray($option);
}
if (self::$config instanceof DataArray) {
return self::$config->get();
}
return [];
}
/**
* 静态魔术加载方法
* @param $name
* @param $arguments
* @return mixed
*/
public static function __callStatic($name , $arguments)
{
$name = ucfirst(strtolower($name));
$class = "\\ByteDance\\{$name}";
if (!empty($class) && class_exists($class)) {
$option = array_shift($arguments);
$config = is_array($option) ? $option : self::$config->get();
return new $class($config);
}
}
}