Passed
Push — master ( b25060...4672bf )
by Vladimir
02:19
created

ChannelServiceProvider   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 23
ccs 0
cts 5
cp 0
rs 10
c 0
b 0
f 0
wmc 1
lcom 1
cbo 4

1 Method

Rating   Name   Duplication   Size   Complexity  
A register() 0 15 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace FondBot\Channels;
6
7
use Illuminate\Support\ServiceProvider;
8
9
class ChannelServiceProvider extends ServiceProvider
10
{
11
    /**
12
     * Register the service provider.
13
     *
14
     * @return void
15
     */
16
    public function register(): void
17
    {
18
        $this->app->singleton(ChannelManager::class, function () {
19
            return tap(new ChannelManager($this->app), function (ChannelManager $manager) {
0 ignored issues
show
Compatibility introduced by
$this->app of type object<Illuminate\Contra...Foundation\Application> is not a sub-type of object<Illuminate\Foundation\Application>. It seems like you assume a concrete implementation of the interface Illuminate\Contracts\Foundation\Application to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
20
                /** @var array $channels */
21
                $channels = collect(config('fondbot.channels'))
22
                    ->mapWithKeys(function (array $parameters, string $name) {
23
                        return [$name => $parameters];
24
                    })
25
                    ->toArray();
26
27
                $manager->register($channels);
28
            });
29
        });
30
    }
31
}
32