Email::init()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 5
c 1
b 0
f 0
nc 2
nop 2
dl 0
loc 8
rs 10
1
<?php
2
namespace tinymeng\mailer;
3
4
/**
5
 * Class Name: PHP Mailer类
6
 * @author Tinymeng <[email protected]>
7
 * @date: 2019/9/26 16:49
8
 * @method static \tinymeng\mailer\Gateways\Smtp smtp(array $config) SMTP发送邮件
9
 * @package tinymeng\mailer
10
 */
11
class Email
12
{
13
    /**
14
     * Description:  init
15
     * @author: JiaMeng <[email protected]>
16
     * Updater:
17
     * @param $gateway
18
     * @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...
19
     * @return mixed
20
     * @throws \Exception
21
     */
22
    protected static function init($gateway, $config = null)
23
    {
24
        $class = __NAMESPACE__ . '\\Gateways\\' . ucfirst(strtolower($gateway));
25
        if (class_exists($class)) {
26
            $app = new $class($config);
27
            return $app;
28
        }
29
        throw new \Exception("发送Mailer基类 [$gateway] 不存在");
30
    }
31
32
    /**
33
     * Description:  __callStatic
34
     * @author: JiaMeng <[email protected]>
35
     * Updater:
36
     * @param $gateway
37
     * @param $config
38
     * @return mixed
39
     */
40
    public static function __callStatic($gateway, $config)
41
    {
42
        return self::init($gateway, ...$config);
0 ignored issues
show
Bug introduced by
$config is expanded, but the parameter $config of tinymeng\mailer\Email::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

42
        return self::init($gateway, /** @scrutinizer ignore-type */ ...$config);
Loading history...
43
    }
44
45
}
46