forked from prooph/event-store
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEventStoreSubscription.php
52 lines (41 loc) · 1.15 KB
/
EventStoreSubscription.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
/**
* This file is part of prooph/event-store.
* (c) 2014-2022 Alexander Miertsch <[email protected]>
* (c) 2015-2022 Sascha-Oliver Prolic <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Prooph\EventStore;
/** @psalm-immutable */
abstract class EventStoreSubscription
{
private bool $isSubscribedToAll;
public function __construct(private string $streamId, private int $lastCommitPosition, private ?int $lastEventNumber)
{
$this->isSubscribedToAll = empty($streamId);
}
public function isSubscribedToAll(): bool
{
return $this->isSubscribedToAll;
}
public function streamId(): string
{
return $this->streamId;
}
public function lastCommitPosition(): int
{
return $this->lastCommitPosition;
}
public function lastEventNumber(): ?int
{
return $this->lastEventNumber;
}
public function close(): void
{
$this->unsubscribe();
}
abstract public function unsubscribe(): void;
}