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.

BroadcastEvent   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A withAnalytics() 0 5 1
A handle() 0 13 3
A __construct() 0 3 1
1
<?php
2
3
namespace ProtoneMedia\AnalyticsEventTracking\Analytics;
4
5
use TheIconic\Tracking\GoogleAnalytics\Analytics;
6
7
class BroadcastEvent implements EventBroadcaster
8
{
9
    private Analytics $analytics;
10
11
    public function __construct(Analytics $analytics)
12
    {
13
        $this->analytics = $analytics;
14
    }
15
16
    /**
17
     * Call the callback with the Analytics instance.
18
     */
19
    public function withAnalytics(callable $callback): self
20
    {
21
        $callback($this->analytics);
22
23
        return $this;
24
    }
25
26
    /**
27
     * Sets the name of the EventAction, calls the 'withAnalytics' method
28
     * on the events if it exists and then sends the event
29
     * to Google Analytics.
30
     */
31
    public function handle($event): void
32
    {
33
        $eventAction = method_exists($event, 'broadcastAnalyticsActionAs')
34
            ? $event->broadcastAnalyticsActionAs($this->analytics)
35
            : class_basename($event);
36
37
        $this->analytics->setEventAction($eventAction);
38
39
        if (method_exists($event, 'withAnalytics')) {
40
            $event->withAnalytics($this->analytics);
41
        }
42
43
        $this->analytics->sendEvent();
44
    }
45
}
46