Completed
Push — master ( 4510f4...5094ff )
by Vladimir
09:59
created

ChannelServiceProvider::channels()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace FondBot\Foundation\Providers;
6
7
use FondBot\Framework\Application;
8
use FondBot\Channels\ChannelManager;
9
use FondBot\Contracts\Channels\Manager;
10
use Illuminate\Support\ServiceProvider;
11
12
/**
13
 * @property Application $app
14
 */
15
class ChannelServiceProvider extends ServiceProvider
16
{
17
    /**
18
     * Register application services.
19
     */
20 88
    public function register(): void
21
    {
22 88
        $this->registerManager();
23 88
    }
24
25
    /**
26
     * Boot application services.
27
     */
28 88
    public function boot(): void
29
    {
30
        /** @var ChannelManager $manager */
31 88
        $manager = $this->app[Manager::class];
32
33 88
        $manager->register(
34 88
            collect($this->channels())
35 88
                ->mapWithKeys(function (array $parameters, string $name) {
36
                    return [$name => $parameters];
37 88
                })
38 88
                ->toArray()
39
        );
40 88
    }
41
42
    /**
43
     * Define bot channels.
44
     *
45
     * @return array
46
     */
47 88
    protected function channels(): array
48
    {
49 88
        return [];
50
    }
51
52
    private function registerManager(): void
53
    {
54 88
        $this->app->singleton(Manager::class, function () {
55 88
            return new ChannelManager($this->app);
0 ignored issues
show
Unused Code introduced by
The call to ChannelManager::__construct() has too many arguments starting with $this->app.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
56 88
        });
57
58 88
        $this->app->alias(Manager::class, ChannelManager::class);
59 88
    }
60
}
61