| Conditions | 3 |
| Paths | 3 |
| Total Lines | 12 |
| Code Lines | 8 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 54 | public function getConnection() { |
||
| 55 | if (!empty($this->socket)) return $this->socket; |
||
| 56 | |||
| 57 | $this->socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); |
||
| 58 | socket_set_option($this->socket, getprotobyname('TCP'), TCP_NODELAY, 1); |
||
| 59 | socket_set_option($this->socket, SOL_SOCKET, SO_RCVTIMEO, ["sec" => self::STREAM_TIMEOUT, "usec" => 0]); |
||
| 60 | if (!socket_connect($this->socket, $this->host, $this->port)) { |
||
| 61 | throw new ConnectionException("Unable to connect to Cassandra node: {$this->host}:{$this->port}"); |
||
| 62 | } |
||
| 63 | |||
| 64 | return $this->socket; |
||
| 65 | } |
||
| 66 | |||
| 73 | } |