DelegationTo::push()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the EasyWeChatComposer.
7
 *
8
 * (c) 张铭阳 <[email protected]>
9
 *
10
 * This source file is subject to the MIT license that is bundled
11
 * with this source code in the file LICENSE.
12
 */
13
14
namespace EasyWeChatComposer\Delegation;
15
16
use EasyWeChatComposer\Traits\MakesHttpRequests;
17
18
class DelegationTo
19
{
20
    use MakesHttpRequests;
21
22
    /**
23
     * @var \EasyWeChat\Kernel\ServiceContainer
0 ignored issues
show
Bug introduced by
The type EasyWeChat\Kernel\ServiceContainer 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...
24
     */
25
    protected $app;
26
27
    /**
28
     * @var array
29
     */
30
    protected $identifiers = [];
31
32
    /**
33
     * @param \EasyWeChat\Kernel\ServiceContainer $app
34
     * @param string                              $identifier
35
     */
36
    public function __construct($app, $identifier)
37
    {
38
        $this->app = $app;
39
40
        $this->push($identifier);
41
    }
42
43
    /**
44
     * @param string $identifier
45
     */
46
    public function push($identifier)
47
    {
48
        $this->identifiers[] = $identifier;
49
    }
50
51
    /**
52
     * @param string $identifier
53
     *
54
     * @return $this
55
     */
56
    public function __get($identifier)
57
    {
58
        $this->push($identifier);
59
60
        return $this;
61
    }
62
63
    /**
64
     * @param string $method
65
     * @param array  $arguments
66
     *
67
     * @return mixed
68
     */
69
    public function __call($method, $arguments)
70
    {
71
        $config = array_intersect_key($this->app->getConfig(), array_flip(['app_id', 'secret', 'token', 'aes_key', 'response_type', 'component_app_id', 'refresh_token']));
72
73
        $data = [
74
            'config' => $config,
75
            'application' => get_class($this->app),
76
            'identifiers' => $this->identifiers,
77
            'method' => $method,
78
            'arguments' => $arguments,
79
        ];
80
81
        return $this->request('easywechat-composer/delegate', $data);
82
    }
83
}
84