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.

PushEventThroughQueueWithCommandId::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 4
dl 0
loc 11
rs 9.9
c 0
b 0
f 0
1
<?php declare(strict_types=1);
2
3
namespace SmoothPhp\LaravelAdapter\StrongConsistency;
4
5
use Illuminate\Contracts\Config\Repository;
6
use Illuminate\Contracts\Queue\Queue;
7
use SmoothPhp\Contracts\CommandBus\CommandBus;
8
use SmoothPhp\Contracts\Domain\DomainMessage;
9
use SmoothPhp\Contracts\EventBus\EventListener;
10
use SmoothPhp\Contracts\Serialization\Serializer;
11
12
/**
13
 * Class PushEventThroughQueueWithCommandId
14
 * @package SmoothPhp\LaravelAdapter\StrongConsistency
15
 * @author Simon Bennett <[email protected]>
16
 */
17
final class PushEventThroughQueueWithCommandId implements EventListener
18
{
19
    /** @var Queue */
20
    private $queue;
21
22
    /** @var Serializer */
23
    private $serializer;
24
25
    /** @var NotificationsCommandBus */
26
    private $notificationsCommandBus;
27
    /** @var Repository */
28
    private $config;
29
30
    /**
31
     * PushEventsThroughQueue constructor.
32
     * @param Queue $queue
33
     * @param Serializer $serializer
34
     * @param StrongConsistencyCommandBusMiddleware|CommandBus $notificationsCommandBus
35
     * @param Repository $config
36
     */
37
    public function __construct(
38
        Queue $queue,
39
        Serializer $serializer,
40
        StrongConsistencyCommandBusMiddleware $notificationsCommandBus,
41
        Repository $config
42
    ) {
43
        $this->queue = $queue;
44
        $this->serializer = $serializer;
45
        $this->notificationsCommandBus = $notificationsCommandBus;
0 ignored issues
show
Documentation Bug introduced by
It seems like $notificationsCommandBus of type object<SmoothPhp\Laravel...cyCommandBusMiddleware> is incompatible with the declared type object<SmoothPhp\Laravel...otificationsCommandBus> of property $notificationsCommandBus.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
46
        $this->config = $config;
47
    }
48
49
    /**
50
     * @param DomainMessage $domainMessage
51
     * @return void
52
     */
53 View Code Duplication
    public function handle(DomainMessage $domainMessage)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
54
    {
55
        $this->queue->push(
56
            QueueToEventDispatcherWithCommandId::class,
57
            [
58
                'uuid'        => (string)$domainMessage->getId(),
59
                'playhead'    => $domainMessage->getPlayHead(),
60
                'metadata'    => json_encode($this->serializer->serialize($domainMessage->getMetadata())),
61
                'payload'     => json_encode($this->serializer->serialize($domainMessage->getPayload())),
62
                'recorded_on' => (string)$domainMessage->getRecordedOn(),
63
                'type'        => $domainMessage->getType(),
64
                'command_id'  => $this->notificationsCommandBus->getLastCommandId(),
65
            ],
66
            $this->config->get('cqrses.queue_name', 'default')
67
        );
68
    }
69
}
70