| Conditions | 3 |
| Paths | 4 |
| Total Lines | 32 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 15 |
| CRAP Score | 3 |
| Changes | 0 | ||
| 1 | <?php |
||
| 16 | 7 | private function openSocket() |
|
| 17 | { |
||
| 18 | // Default: Context for ssl |
||
| 19 | 7 | $context = stream_context_create([ |
|
| 20 | 7 | 'ssl' => [ |
|
| 21 | 'ciphers' => 'ADH:ALL', |
||
| 22 | 'verify_peer' => false, |
||
| 23 | 'verify_peer_name' => false |
||
| 24 | ] |
||
| 25 | ]); |
||
| 26 | |||
| 27 | // Default: Proto tcp:// but for ssl we need ssl:// |
||
| 28 | 7 | $proto = $this->config('ssl') ? 'ssl://' : ''; |
|
|
|
|||
| 29 | |||
| 30 | // Initiate socket client |
||
| 31 | 7 | $socket = @stream_socket_client( |
|
| 32 | 7 | $proto . $this->config('host') . ':' . $this->config('port'), |
|
| 33 | 7 | $this->_socket_err_num, |
|
| 34 | 7 | $this->_socket_err_str, |
|
| 35 | 7 | $this->config('timeout'), |
|
| 36 | 7 | STREAM_CLIENT_CONNECT, |
|
| 37 | 7 | $context |
|
| 38 | ); |
||
| 39 | |||
| 40 | // Throw error is socket is not initiated |
||
| 41 | 7 | if (!$socket) { |
|
| 42 | 1 | throw new ClientException('Unable to establish socket session, ' . $this->_socket_err_str); |
|
| 43 | } |
||
| 44 | |||
| 45 | // Save socket to static variable |
||
| 46 | 6 | $this->setSocket($socket); |
|
| 47 | 6 | } |
|
| 48 | |||
| 80 |
This check looks for methods that are used by a trait but not required by it.
To illustrate, let’s look at the following code example
The trait
Idableprovides a methodequalsIdthat in turn relies on the methodgetId(). If this method does not exist on a class mixing in this trait, the method will fail.Adding the
getId()as an abstract method to the trait will make sure it is available.