Factory::__callStatic()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 2
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
/*
4
 * This file is part of the overtrue/wechat.
5
 *
6
 * (c) overtrue <[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 EasyWeChat;
13
14
/**
15
 * Class Factory.
16
 *
17
 * @method static \EasyWeChat\Payment\Application            payment(array $config)
18
 * @method static \EasyWeChat\MiniProgram\Application        miniProgram(array $config)
19
 * @method static \EasyWeChat\OpenPlatform\Application       openPlatform(array $config)
20
 * @method static \EasyWeChat\OfficialAccount\Application    officialAccount(array $config)
21
 * @method static \EasyWeChat\BasicService\Application       basicService(array $config)
22
 * @method static \EasyWeChat\Work\Application               work(array $config)
23
 * @method static \EasyWeChat\OpenWork\Application           openWork(array $config)
24
 * @method static \EasyWeChat\MicroMerchant\Application      microMerchant(array $config)
25
 */
26
class Factory
27
{
28
    /**
29
     * @param string $name
30
     * @param array  $config
31
     *
32
     * @return \EasyWeChat\Kernel\ServiceContainer
33
     */
34 1
    public static function make($name, array $config)
35
    {
36 1
        $namespace = Kernel\Support\Str::studly($name);
37 1
        $application = "\\EasyWeChat\\{$namespace}\\Application";
38
39 1
        return new $application($config);
40
    }
41
42
    /**
43
     * Dynamically pass methods to the application.
44
     *
45
     * @param string $name
46
     * @param array  $arguments
47
     *
48
     * @return mixed
49
     */
50 1
    public static function __callStatic($name, $arguments)
51
    {
52 1
        return self::make($name, ...$arguments);
0 ignored issues
show
Bug introduced by
$arguments is expanded, but the parameter $config of EasyWeChat\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

52
        return self::make($name, /** @scrutinizer ignore-type */ ...$arguments);
Loading history...
53
    }
54
}
55