Generate.php
1.4 KB
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
<?php
namespace tinymeng\code;
use \tinymeng\tools\Strings;
/**
* Class Name: PHP 生成二维码Code类
* @author Tinymeng <666@majiameng.com>
* @date: 2019/9/26 16:49
* @method static \tinymeng\code\Gateways\Bar bar(array $config=[]) 条形码
* @method static \tinymeng\code\Gateways\Qr qr(array $config=[]) 二维码
* @package tinymeng\mailer
*/
define('saveFilePath',dirname(dirname(dirname(dirname(__DIR__)))).DIRECTORY_SEPARATOR.'public'.DIRECTORY_SEPARATOR.'uploads'.DIRECTORY_SEPARATOR.'barimages'.DIRECTORY_SEPARATOR.date('Ymd').DIRECTORY_SEPARATOR);
class Generate
{
/**
* Description: init
* @author: JiaMeng <666@majiameng.com>
* Updater:
* @param $gateway
* @param null $config
* @return mixed
* @throws \Exception
*/
protected static function init($gateway, $config = null)
{
$class = __NAMESPACE__ . '\\Gateways\\' . Strings::uFirst($gateway);
if (class_exists($class)) {
$app = new $class($config);
return $app;
}
throw new \Exception("发送QR Code基类 [$gateway] 不存在");
}
/**
* Description: __callStatic
* @author: JiaMeng <666@majiameng.com>
* Updater:
* @param $gateway
* @param $config
* @return mixed
*/
public static function __callStatic($gateway, $config)
{
return self::init($gateway, ...$config);
}
}