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

Notification   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 37
rs 10
c 0
b 0
f 0
wmc 4
lcom 0
cbo 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A getChannel() 0 4 1
A getPayload() 0 4 1
A getSenderBackendPID() 0 4 1
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