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::withAnalytics()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 5
rs 10
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