Completed
Push — master ( aa5a73...5f3c84 )
by Ondřej
02:54
created

Notification::getPid()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
declare(strict_types=1);
3
4
namespace Ivory\Connection;
5
6
/**
7
 * Notification received from an IPC channel.
8
 *
9
 * The objects are immutable.
10
 */
11
class Notification
12
{
13
    private $channel;
14
    private $pid;
15
    private $payload;
16
17
    public function __construct(string $channel, int $pid, ?string $payload)
18
    {
19
        $this->channel = $channel;
20
        $this->pid = $pid;
21
        $this->payload = $payload;
22
    }
23
24
    /**
25
     * @return string name of the IPC channel the notification was sent through
26
     */
27
    public function getChannel(): string
28
    {
29
        return $this->channel;
30
    }
31
32
    /**
33
     * @return int ID of the database server process which sent the notification
34
     */
35
    public function getSenderBackendPID(): int
36
    {
37
        return $this->pid;
38
    }
39
40
    /**
41
     * @return string|null the notification payload, or <tt>null</tt> if no payload is contained
42
     */
43
    public function getPayload(): ?string
44
    {
45
        return $this->payload;
46
    }
47
}
48