PrivateUserChannelParameters   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Test Coverage

Coverage 63.64%

Importance

Changes 0
Metric Value
wmc 1
eloc 13
c 0
b 0
f 0
dl 0
loc 21
ccs 7
cts 11
cp 0.6364
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 19 1
1
<?php
2
3
namespace MallardDuck\DynamicEcho\Channels;
4
5
use App\Models\User;
0 ignored issues
show
Bug introduced by
The type App\Models\User 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...
6
use Illuminate\Http\Request;
7
use MallardDuck\DynamicEcho\Contracts\HasDynamicChannelFormula;
8
9
/**
10
 * Class PrivateChannelParameters
11
 *
12
 * @mixin AbstractChannelParameters
13
 */
14
final class PrivateUserChannelParameters extends AbstractChannelParameters
15
{
16 1
    public function __construct()
17
    {
18 1
        $this->channelType = \Illuminate\Broadcasting\PrivateChannel::class;
19 1
        $this->channelAuthName = 'App.Models.User.{userId}';
20 1
        $this->channelAuthCallback = static function (User $user, $userId) {
21
            return (int) $user->id === (int) $userId;
22
        };
23 1
        $this->channelContextBindingCallback = static function (Request $request) {
24
            return [
25
                'userId' => $request->user()->id
26
            ];
27
        };
28 1
        $this->eventChannelIdentifierBindingCallback = static function (HasDynamicChannelFormula $event) {
29
            $self = $event;
30
            return [
31
                'userId' => $self->userId,
0 ignored issues
show
Bug introduced by
Accessing userId on the interface MallardDuck\DynamicEcho\...asDynamicChannelFormula suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
32
            ];
33
        };
34 1
        parent::__construct();
35 1
    }
36
}
37