Factory::__callStatic()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 2
dl 0
loc 5
ccs 0
cts 4
cp 0
crap 2
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
/*
4
 * This file is part of the docodeit/wechat.
5
 *
6
 * (c) docodeit <[email protected]>
7
 *
8
 * This source file is subject to the MIT license that is bundled
9
 * with this source code in the file LICENSE.
10
 */
11
12
namespace JinWeChat;
13
14
/**
15
 * 入口文件.
16
 *
17
 * @method static OfficialAccount\Application    officialAccount(array $config)
18
 **/
19
class Factory
20
{
21
    /**
22
     * @param $name
23
     * @param array $config
24
     *
25
     * @return mixed
26
     */
27
    public static function make($name, array $config)
28
    {
29
        $application = "\\JinWeChat\\{$name}\\Application";
30
31
        return new $application($config);
32
    }
33
34
    /**
35
     * @param $name
36
     * @param $args
37
     *
38
     * @return mixed
39
     */
40
    public static function __callStatic($name, $args)
41
    {
42
        $name = ucwords(str_replace(['-', '_'], ' ', $name));
43
44
        return self::make($name, ...$args);
0 ignored issues
show
Bug introduced by
$args is expanded, but the parameter $config of JinWeChat\Factory::make() 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

44
        return self::make($name, /** @scrutinizer ignore-type */ ...$args);
Loading history...
45
    }
46
}
47