Issues (35)

src/Traits/WithAggregator.php (2 issues)

Labels
Severity
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\Traits;
15
16
use EasyWeChat\Kernel\BaseClient;
0 ignored issues
show
The type EasyWeChat\Kernel\BaseClient 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...
17
use EasyWeChatComposer\Delegation\DelegationTo;
18
use EasyWeChatComposer\EasyWeChat;
19
20
trait WithAggregator
21
{
22
    /**
23
     * Aggregate.
24
     */
25
    protected function aggregate()
26
    {
27
        foreach (EasyWeChat::config() as $key => $value) {
28
            $this['config']->set($key, $value);
29
        }
30
    }
31
32
    /**
33
     * @return bool
34
     */
35
    public function shouldDelegate($id)
36
    {
37
        return $this['config']->get('delegation.enabled')
38
            && $this->offsetGet($id) instanceof BaseClient;
0 ignored issues
show
It seems like offsetGet() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

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

38
            && $this->/** @scrutinizer ignore-call */ offsetGet($id) instanceof BaseClient;
Loading history...
39
    }
40
41
    /**
42
     * @return $this
43
     */
44
    public function shouldntDelegate()
45
    {
46
        $this['config']->set('delegation.enabled', false);
47
48
        return $this;
49
    }
50
51
    /**
52
     * @param string $id
53
     *
54
     * @return \EasyWeChatComposer\Delegation
55
     */
56
    public function delegateTo($id)
57
    {
58
        return new DelegationTo($this, $id);
59
    }
60
}
61