@@ -72,16 +72,16 @@ discard block |
||
| 72 | 72 | $mode = "wb"; |
| 73 | 73 | |
| 74 | 74 | if (file_exists($file)) { |
| 75 | - if (! $append) { |
|
| 75 | + if (!$append) { |
|
| 76 | 76 | throw new FileExistsException("File $file already exists!"); |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | - if (! is_writable($file)) { |
|
| 79 | + if (!is_writable($file)) { |
|
| 80 | 80 | throw new NoAccessException("Cannot write to file $file"); |
| 81 | 81 | } |
| 82 | 82 | $mode = "ab"; |
| 83 | 83 | } else { |
| 84 | - if (! is_writable(dirname($file))) { |
|
| 84 | + if (!is_writable(dirname($file))) { |
|
| 85 | 85 | throw new NoAccessException("Cannot write to file {file}", array( |
| 86 | 86 | 'file' => $file |
| 87 | 87 | )); |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | |
| 91 | 91 | $this->handle = fopen($file, $mode); |
| 92 | 92 | |
| 93 | - if (! $this->ready()) { |
|
| 93 | + if (!$this->ready()) { |
|
| 94 | 94 | throw new StreamException("Could not open {file} for writing", array( |
| 95 | 95 | 'file' => $file |
| 96 | 96 | )); |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | */ |
| 130 | 130 | public function write($buffer) |
| 131 | 131 | { |
| 132 | - if (! $this->ready()) { |
|
| 132 | + if (!$this->ready()) { |
|
| 133 | 133 | throw new StreamException("Stream is not open!"); |
| 134 | 134 | } |
| 135 | 135 | |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | */ |
| 170 | 170 | public function count():int |
| 171 | 171 | { |
| 172 | - if (! $this->ready()) { |
|
| 172 | + if (!$this->ready()) { |
|
| 173 | 173 | throw new StreamException("Stream is not open!"); |
| 174 | 174 | } |
| 175 | 175 | |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | */ |
| 202 | 202 | public function flush() |
| 203 | 203 | { |
| 204 | - if (! $this->ready()) { |
|
| 204 | + if (!$this->ready()) { |
|
| 205 | 205 | throw new StreamException("Stream is not open!"); |
| 206 | 206 | } |
| 207 | 207 | |
@@ -260,7 +260,7 @@ discard block |
||
| 260 | 260 | $this->close(); |
| 261 | 261 | $this->open($this->fileName, $this->append); |
| 262 | 262 | } |
| 263 | - catch(Exception $ex) |
|
| 263 | + catch (Exception $ex) |
|
| 264 | 264 | { |
| 265 | 265 | throw new ResetException($ex->getMessage(), array(), $ex->getCode(), $ex); |
| 266 | 266 | } |
@@ -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 | } |