GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

RedisCommandExecuted   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
eloc 17
c 1
b 0
f 0
dl 0
loc 32
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A handleEvent() 0 9 1
A formatCommand() 0 17 4
1
<?php
2
3
namespace Honeybadger\HoneybadgerLaravel\Breadcrumbs;
4
5
use Honeybadger\HoneybadgerLaravel\Facades\Honeybadger;
6
use Illuminate\Redis\Events\CommandExecuted;
7
8
/**
9
 * Note that Laravel only dispatches Redis events if the user calls Redis::enableEvents() first.
10
 */
11
class RedisCommandExecuted extends Breadcrumb
12
{
13
    public $handles = CommandExecuted::class;
14
15
    public function handleEvent(CommandExecuted $event)
16
    {
17
        $metadata = [
18
            'connectionName' => $event->connectionName,
19
            'command' => $this->formatCommand($event->command, $event->parameters),
20
            'duration' => number_format($event->time, 2, '.', '').'ms',
21
        ];
22
23
        Honeybadger::addBreadcrumb('Redis command executed', $metadata, 'query');
24
    }
25
26
    private function formatCommand(string $command, array $parameters)
27
    {
28
        $parameters = collect($parameters)->map(function ($parameter) {
0 ignored issues
show
Bug introduced by
$parameters of type array is incompatible with the type Illuminate\Contracts\Support\Arrayable expected by parameter $value of collect(). ( Ignorable by Annotation )

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

28
        $parameters = collect(/** @scrutinizer ignore-type */ $parameters)->map(function ($parameter) {
Loading history...
29
            if (is_array($parameter)) {
30
                return collect($parameter)->map(function ($value, $key) {
0 ignored issues
show
Bug introduced by
$parameter of type array is incompatible with the type Illuminate\Contracts\Support\Arrayable expected by parameter $value of collect(). ( Ignorable by Annotation )

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

30
                return collect(/** @scrutinizer ignore-type */ $parameter)->map(function ($value, $key) {
Loading history...
31
                    if (is_array($value)) {
32
                        return json_encode($value);
33
                    }
34
35
                    return is_int($key) ? $value : "{$key} {$value}";
36
                })->implode(' ');
37
            }
38
39
            return $parameter;
40
        })->implode(' ');
41
42
        return "{$command} {$parameters}";
43
    }
44
}
45