Lines 0.00% 0 / 6
Functions and Methods 0.00% 0 / 4
Classes and Traits 0.00% 0 / 1
Name Lines Functions and Methods CRAP Classes and Traits
SubscriptionActivity 0.00% 0 / 6 0.00% 0 / 4 20 0.00% 0 / 1
 __construct 0.00% 0 / 1 0.00% 0 / 1 2
 recordReceived 0.00% 0 / 2 0.00% 0 / 1 2
 recordHandled 0.00% 0 / 2 0.00% 0 / 1 2
 recordDropped 0.00% 0 / 1 0.00% 0 / 1 2
1<?php
2
3declare(strict_types=1);
4
5namespace Stewart\Runtime\Dispatch;
6
7use Stewart\Contracts\Time\Instant;
8
9final class SubscriptionActivity
10{
11    public private(set) int $received = 0;
12
13    public private(set) int $handled = 0;
14
15    public private(set) int $dropped = 0;
16
17    public private(set) ?Instant $lastReceivedAt = null;
18
19    public private(set) ?Instant $lastHandledAt = null;
20
21    public function __construct(public readonly RegisteredSubscription $subscription) {}
22
23    public function recordReceived(Instant $at): void
24    {
25        ++$this->received;
26        $this->lastReceivedAt = $at;
27    }
28
29    public function recordHandled(Instant $at): void
30    {
31        ++$this->handled;
32        $this->lastHandledAt = $at;
33    }
34
35    public function recordDropped(): void
36    {
37        ++$this->dropped;
38    }
39}