|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* TStreamNotificationParameter class file |
|
4
|
|
|
* |
|
5
|
|
|
* @author Brad Anderson <[email protected]> |
|
6
|
|
|
* @link https://github.com/pradosoft/prado |
|
7
|
|
|
* @license https://github.com/pradosoft/prado/blob/master/LICENSE |
|
8
|
|
|
*/ |
|
9
|
|
|
|
|
10
|
|
|
namespace Prado\IO; |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* TStreamNotificationParameter class. |
|
14
|
|
|
* |
|
15
|
|
|
* This class parameterizes the Stream Notification Callback arguments into a structure |
|
16
|
|
|
* for raising PRADO Stream Notification Events. |
|
17
|
|
|
* |
|
18
|
|
|
* @author Brad Anderson <[email protected]> |
|
19
|
|
|
* @since 4.2.3 |
|
20
|
|
|
* @link https://www.php.net/manual/en/function.stream-notification-callback.php |
|
21
|
|
|
*/ |
|
22
|
|
|
class TStreamNotificationParameter extends \Prado\TEventParameter |
|
23
|
|
|
{ |
|
24
|
|
|
/** @var int One of the STREAM_NOTIFY_* notification constants. */ |
|
25
|
|
|
private int $_notification_code; |
|
26
|
|
|
|
|
27
|
|
|
/** @var int One of the STREAM_NOTIFY_SEVERITY_* notification constants. */ |
|
28
|
|
|
private int $_severity; |
|
29
|
|
|
|
|
30
|
|
|
/** @var ?string Passed if a descriptive message is available for the event. */ |
|
31
|
|
|
private ?string $_message; |
|
32
|
|
|
|
|
33
|
|
|
/** @var int Passed if a descriptive message code is available for the event. */ |
|
34
|
|
|
private int $_message_code; |
|
35
|
|
|
|
|
36
|
|
|
/** @var int If applicable, the bytes_transferred will be populated. */ |
|
37
|
|
|
private int $_bytes_transferred; |
|
38
|
|
|
|
|
39
|
|
|
/** @var int If applicable, the bytes_max will be populated. */ |
|
40
|
|
|
private int $_bytes_max; |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* @param int $notification_code One of the STREAM_NOTIFY_* notification constants. |
|
44
|
|
|
* @param int $severity One of the STREAM_NOTIFY_SEVERITY_* notification constants. |
|
45
|
|
|
* @param ?string $message Passed if a descriptive message is available for the event. |
|
46
|
|
|
* @param int $message_code Passed if a descriptive message code is available for the event. |
|
47
|
|
|
* @param int $bytes_transferred If applicable, the bytes_transferred will be populated. |
|
48
|
|
|
* @param int $bytes_max If applicable, the bytes_max will be populated. |
|
49
|
|
|
*/ |
|
50
|
|
|
public function __construct(int $notification_code = 0, int $severity = 0, ?string $message = null, int $message_code = 0, int $bytes_transferred = 0, int $bytes_max = 0) |
|
51
|
|
|
{ |
|
52
|
|
|
$this->setNotificationCode($notification_code); |
|
53
|
|
|
$this->setSeverity($severity); |
|
54
|
|
|
$this->setMessage($message); |
|
55
|
|
|
$this->setMessageCode($message_code); |
|
56
|
|
|
$this->setBytesTransferred($bytes_transferred); |
|
57
|
|
|
$this->setBytesMax($bytes_max); |
|
58
|
|
|
parent::__construct(); |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* @return int One of the STREAM_NOTIFY_* notification constants. |
|
63
|
|
|
*/ |
|
64
|
|
|
public function getNotificationCode(): int |
|
65
|
|
|
{ |
|
66
|
|
|
return $this->_notification_code; |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
/** |
|
70
|
|
|
* @param int $value One of the STREAM_NOTIFY_* notification constants. |
|
71
|
|
|
*/ |
|
72
|
|
|
public function setNotificationCode(int $value): void |
|
73
|
|
|
{ |
|
74
|
|
|
$this->_notification_code = $value; |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
/** |
|
78
|
|
|
* @return int One of the STREAM_NOTIFY_SEVERITY_* notification constants. |
|
79
|
|
|
*/ |
|
80
|
|
|
public function getSeverity(): int |
|
81
|
|
|
{ |
|
82
|
|
|
return $this->_severity; |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
|
|
/** |
|
86
|
|
|
* @param int $value One of the STREAM_NOTIFY_SEVERITY_* notification constants. |
|
87
|
|
|
*/ |
|
88
|
|
|
public function setSeverity(int $value): void |
|
89
|
|
|
{ |
|
90
|
|
|
$this->_severity = $value; |
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
|
|
/** |
|
94
|
|
|
* @return ?string Passed if a descriptive message is available for the event. |
|
95
|
|
|
*/ |
|
96
|
|
|
public function getMessage(): ?string |
|
97
|
|
|
{ |
|
98
|
|
|
return $this->_message; |
|
99
|
|
|
} |
|
100
|
|
|
|
|
101
|
|
|
/** |
|
102
|
|
|
* @param ?string $value Passed if a descriptive message is available for the event. |
|
103
|
|
|
*/ |
|
104
|
|
|
public function setMessage(?string $value): void |
|
105
|
|
|
{ |
|
106
|
|
|
$this->_message = $value; |
|
107
|
|
|
} |
|
108
|
|
|
|
|
109
|
|
|
/** |
|
110
|
|
|
* @return int Passed if a descriptive message code is available for the event. |
|
111
|
|
|
*/ |
|
112
|
|
|
public function getMessageCode(): int |
|
113
|
|
|
{ |
|
114
|
|
|
return $this->_message_code; |
|
115
|
|
|
} |
|
116
|
|
|
|
|
117
|
|
|
/** |
|
118
|
|
|
* @param int $value Passed if a descriptive message code is available for the event. |
|
119
|
|
|
*/ |
|
120
|
|
|
public function setMessageCode(int $value): void |
|
121
|
|
|
{ |
|
122
|
|
|
$this->_message_code = $value; |
|
123
|
|
|
} |
|
124
|
|
|
|
|
125
|
|
|
/** |
|
126
|
|
|
* @return int If applicable, the bytes_transferred will be populated. |
|
127
|
|
|
*/ |
|
128
|
|
|
public function getBytesTransferred(): int |
|
129
|
|
|
{ |
|
130
|
|
|
return $this->_bytes_transferred; |
|
131
|
|
|
} |
|
132
|
|
|
|
|
133
|
|
|
/** |
|
134
|
|
|
* @param int $value If applicable, the bytes_transferred will be populated. |
|
135
|
|
|
*/ |
|
136
|
|
|
public function setBytesTransferred(int $value): void |
|
137
|
|
|
{ |
|
138
|
|
|
$this->_bytes_transferred = $value; |
|
139
|
|
|
} |
|
140
|
|
|
|
|
141
|
|
|
/** |
|
142
|
|
|
* @return int If applicable, the bytes_max will be populated. |
|
143
|
|
|
*/ |
|
144
|
|
|
public function getBytesMax(): int |
|
145
|
|
|
{ |
|
146
|
|
|
return $this->_bytes_max; |
|
147
|
|
|
} |
|
148
|
|
|
|
|
149
|
|
|
/** |
|
150
|
|
|
* @param int $value If applicable, the bytes_max will be populated. |
|
151
|
|
|
*/ |
|
152
|
|
|
public function setBytesMax(int $value): void |
|
153
|
|
|
{ |
|
154
|
|
|
$this->_bytes_max = $value; |
|
155
|
|
|
} |
|
156
|
|
|
} |
|
157
|
|
|
|