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.
Passed
Push — master ( 5938c5...5ca810 )
by Ash
02:42
created

AnalyticTracked   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 14
dl 0
loc 45
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A broadcastWith() 0 8 1
A broadcastOn() 0 3 1
1
<?php
2
3
namespace AshPowell\APAnalytics\Events;
4
5
use Illuminate\Broadcasting\InteractsWithSockets;
6
use Illuminate\Broadcasting\PresenceChannel;
7
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
8
use Illuminate\Foundation\Events\Dispatchable;
9
use Illuminate\Queue\SerializesModels;
10
11
class AnalyticTracked implements ShouldBroadcast
12
{
13
    use Dispatchable, InteractsWithSockets, SerializesModels;
0 ignored issues
show
introduced by
The trait Illuminate\Queue\SerializesModels requires some properties which are not provided by AshPowell\APAnalytics\Events\AnalyticTracked: $id, $class, $connection, $relations
Loading history...
14
15
    public $basename;
16
    public $item;
17
    public $itemId;
18
19
    /**
20
     * Create a new event instance.
21
     *
22
     * @return void
23
     * @param  mixed $item
24
     * @param  mixed $basename
25
     */
26
    public function __construct($basename, $item)
27
    {
28
        $this->basename = $basename;
29
        $this->item     = $item;
30
        $this->itemId   = array_get($this->item, "{$this->basename}.id");
31
    }
32
33
    /**
34
     * Get the channels the event should broadcast on.
35
     *
36
     * @return \Illuminate\Broadcasting\Channel|array
37
     */
38
    public function broadcastOn()
39
    {
40
        return new PresenceChannel('analytics.'.$this->basename.'.'.$this->itemId);
41
    }
42
43
    /**
44
     * Get the data to broadcast.
45
     *
46
     * @return array
47
     */
48
    public function broadcastWith()
49
    {
50
        $created_at = array_get($this->item, 'created_at') ?? mongoTime();
51
52
        return [
53
            'itemType'   => $this->basename,
54
            'itemId'     => $this->itemId,
55
            'created_at' => $created_at->toDateTime()->getTimestamp()
56
        ];
57
    }
58
}
59