@@ -34,8 +34,8 @@ discard block |
||
| 34 | 34 | $this->handle = $clientHandle; |
| 35 | 35 | $this->conntected = false; |
| 36 | 36 | |
| 37 | - if (! is_resource ( $clientHandle )) { |
|
| 38 | - parent::__construct ( $endpoint ); |
|
| 37 | + if (!is_resource($clientHandle)) { |
|
| 38 | + parent::__construct($endpoint); |
|
| 39 | 39 | } |
| 40 | 40 | } |
| 41 | 41 | |
@@ -45,9 +45,9 @@ discard block |
||
| 45 | 45 | * @throws SocketException |
| 46 | 46 | */ |
| 47 | 47 | public function connect() { |
| 48 | - if (! @socket_connect ( $this->handle, $this->endpoint->getAddress (), $this->endpoint->getPort () )) { |
|
| 49 | - $code = socket_last_error ( $this->handle ); |
|
| 50 | - throw new SocketException ( socket_strerror ( $code ), array (), $code ); |
|
| 48 | + if (!@socket_connect($this->handle, $this->endpoint->getAddress(), $this->endpoint->getPort())) { |
|
| 49 | + $code = socket_last_error($this->handle); |
|
| 50 | + throw new SocketException(socket_strerror($code), array(), $code); |
|
| 51 | 51 | } |
| 52 | 52 | $this->conntected = true; |
| 53 | 53 | } |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | * @throws SocketException |
| 59 | 59 | */ |
| 60 | 60 | public function disconnect() { |
| 61 | - $this->close (); |
|
| 61 | + $this->close(); |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | /** |
@@ -75,11 +75,11 @@ discard block |
||
| 75 | 75 | * @see \Generics\Socket\ClientSocket::disconnect() |
| 76 | 76 | */ |
| 77 | 77 | public function close() { |
| 78 | - if (! $this->conntected) { |
|
| 79 | - throw new SocketException ( "Socket is not connected" ); |
|
| 78 | + if (!$this->conntected) { |
|
| 79 | + throw new SocketException("Socket is not connected"); |
|
| 80 | 80 | } |
| 81 | 81 | |
| 82 | - parent::close (); |
|
| 82 | + parent::close(); |
|
| 83 | 83 | $this->conntected = false; |
| 84 | 84 | } |
| 85 | 85 | |
@@ -89,10 +89,10 @@ discard block |
||
| 89 | 89 | * @see \Generics\Socket\Socket::isWriteable() |
| 90 | 90 | */ |
| 91 | 91 | public function isWriteable() { |
| 92 | - if (! $this->isConnected ()) { |
|
| 92 | + if (!$this->isConnected()) { |
|
| 93 | 93 | return false; |
| 94 | 94 | } |
| 95 | 95 | |
| 96 | - return parent::isWriteable (); |
|
| 96 | + return parent::isWriteable(); |
|
| 97 | 97 | } |
| 98 | 98 | } |
@@ -25,13 +25,13 @@ discard block |
||
| 25 | 25 | * @return \Generics\Socket\Url |
| 26 | 26 | */ |
| 27 | 27 | public static function parseUrl($url) { |
| 28 | - $parts = parse_url ( $url ); |
|
| 28 | + $parts = parse_url($url); |
|
| 29 | 29 | |
| 30 | - if (false === $parts || false === Arrays::hasElement ( $parts, 'host' )) { |
|
| 31 | - throw new InvalidUrlException ( 'This URL does not contain a host part' ); |
|
| 30 | + if (false === $parts || false === Arrays::hasElement($parts, 'host')) { |
|
| 31 | + throw new InvalidUrlException('This URL does not contain a host part'); |
|
| 32 | 32 | } |
| 33 | - if (false === $parts || false === Arrays::hasElement ( $parts, 'scheme' )) { |
|
| 34 | - throw new InvalidUrlException ( 'This URL does not contain a scheme part' ); |
|
| 33 | + if (false === $parts || false === Arrays::hasElement($parts, 'scheme')) { |
|
| 34 | + throw new InvalidUrlException('This URL does not contain a scheme part'); |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | $address = $parts ['host']; |
@@ -39,19 +39,19 @@ discard block |
||
| 39 | 39 | $port = 0; |
| 40 | 40 | $path = "/"; |
| 41 | 41 | |
| 42 | - if (isset ( $parts ['port'] )) { |
|
| 43 | - $port = intval ( $parts ['port'] ); |
|
| 42 | + if (isset ($parts ['port'])) { |
|
| 43 | + $port = intval($parts ['port']); |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | if ($port == 0) { |
| 47 | - $port = self::getPortByScheme ( $scheme ); |
|
| 47 | + $port = self::getPortByScheme($scheme); |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | - if (isset ( $parts ['path'] )) { |
|
| 50 | + if (isset ($parts ['path'])) { |
|
| 51 | 51 | $path = $parts ['path']; |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | - return new Url ( $address, $port, $path, $scheme ); |
|
| 54 | + return new Url($address, $port, $path, $scheme); |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | /** |
@@ -76,9 +76,9 @@ discard block |
||
| 76 | 76 | return 21; |
| 77 | 77 | |
| 78 | 78 | default : |
| 79 | - throw new InvalidUrlException ( "Scheme {scheme} is not handled!", array ( |
|
| 79 | + throw new InvalidUrlException("Scheme {scheme} is not handled!", array( |
|
| 80 | 80 | 'scheme' => $scheme |
| 81 | - ) ); |
|
| 81 | + )); |
|
| 82 | 82 | } |
| 83 | 83 | } |
| 84 | 84 | } |