Conditions | 5 |
Paths | 9 |
Total Lines | 28 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
16 | public function write(array $namedParameters): bool |
||
17 | { |
||
18 | if (! $this->socket = $this->socket ?: $this->createSocket()) { |
||
19 | return false; |
||
20 | } |
||
21 | |||
22 | set_error_handler([self::class, 'nullErrorHandler']); |
||
23 | |||
24 | try { |
||
25 | $encodedPayload = base64_encode(serialize($namedParameters))."\n"; |
||
26 | |||
27 | if (-1 !== stream_socket_sendto($this->socket, $encodedPayload)) { |
||
28 | return true; |
||
29 | } |
||
30 | |||
31 | stream_socket_shutdown($this->socket, STREAM_SHUT_RDWR); |
||
32 | fclose($this->socket); |
||
33 | $this->socket = $this->createSocket(); |
||
34 | |||
35 | if (-1 !== stream_socket_sendto($this->socket, $encodedPayload)) { |
||
36 | return true; |
||
37 | } |
||
38 | } finally { |
||
39 | restore_error_handler(); |
||
40 | } |
||
41 | |||
42 | return false; |
||
43 | } |
||
44 | |||
60 |