Issues (99)

src/Generate.php (1 issue)

1
<?php
2
namespace tinymeng\code;
3
4
use \tinymeng\tools\StringTool;
5
/**
6
 * Class Name: PHP 生成二维码Code类
7
 * @author Tinymeng <[email protected]>
8
 * @date: 2019/9/26 16:49
9
 * @method static \tinymeng\code\Gateways\Bar bar(array $config=[]) 条形码
10
 * @method static \tinymeng\code\Gateways\Qr qr(array $config=[]) 二维码
11
 * @package tinymeng\mailer
12
 */
13
define('saveFilePath',dirname(dirname(dirname(dirname(__DIR__)))).DIRECTORY_SEPARATOR.'cache'.DIRECTORY_SEPARATOR.'tinymeng'.DIRECTORY_SEPARATOR.'code'.DIRECTORY_SEPARATOR);
14
15
class Generate
16
{
17
    /**
18
     * Description:  init
19
     * @author: JiaMeng <[email protected]>
20
     * Updater:
21
     * @param $gateway
22
     * @param null $config
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $config is correct as it would always require null to be passed?
Loading history...
23
     * @return mixed
24
     * @throws \Exception
25
     */
26
    protected static function init($gateway, $config = null)
27
    {
28
        $class = __NAMESPACE__ . '\\Gateways\\' . StringTool::uFirst($gateway);
29
        if (class_exists($class)) {
30
            $app = new $class($config);
31
            return $app;
32
        }
33
        throw new \Exception("发送QR Code基类 [$gateway] 不存在");
34
    }
35
36
    /**
37
     * Description:  __callStatic
38
     * @author: JiaMeng <[email protected]>
39
     * Updater:
40
     * @param $gateway
41
     * @param $config
42
     * @return mixed
43
     */
44
    public static function __callStatic($gateway, $config)
45
    {
46
        return self::init($gateway, ...$config);
47
    }
48
49
}
50