Generate::init()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 5
nc 2
nop 2
dl 0
loc 8
rs 10
c 0
b 0
f 0
1
<?php
2
namespace tinymeng\code;
3
4
use \tinymeng\tools\StringTool;
0 ignored issues
show
Bug introduced by
The type \tinymeng\tools\StringTool was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
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);
0 ignored issues
show
Bug introduced by
$config is expanded, but the parameter $config of tinymeng\code\Generate::init() does not expect variable arguments. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

46
        return self::init($gateway, /** @scrutinizer ignore-type */ ...$config);
Loading history...
47
    }
48
49
}
50