Completed
Push — master ( d1d02b...e3e5bf )
by Maik
02:45
created
src/Generics/Logger/BasicLogger.php 2 patches
Indentation   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -8,24 +8,24 @@  discard block
 block discarded – undo
8 8
 
9 9
 abstract class BasicLogger extends AbstractLogger
10 10
 {
11
-	/**
12
-	 * The level threshold where to log
13
-	 * 
14
-	 * @var string
15
-	 */
16
-	private $level;
11
+    /**
12
+     * The level threshold where to log
13
+     * 
14
+     * @var string
15
+     */
16
+    private $level;
17 17
 	
18
-	/**
19
-	 * Set the log level threshold
20
-	 * 
21
-	 * @param string $level
22
-	 * @return BasicLogger
23
-	 */
24
-	public function setLevel(string $level):BasicLogger
25
-	{
26
-		$this->level = $level;
27
-		return $this;
28
-	}
18
+    /**
19
+     * Set the log level threshold
20
+     * 
21
+     * @param string $level
22
+     * @return BasicLogger
23
+     */
24
+    public function setLevel(string $level):BasicLogger
25
+    {
26
+        $this->level = $level;
27
+        return $this;
28
+    }
29 29
 	
30 30
     /**
31 31
      * Checks the given level
@@ -89,32 +89,32 @@  discard block
 block discarded – undo
89 89
      */
90 90
     public function log($level, $message, array $context = array())
91 91
     {
92
-    	if( $this->levelHasReached($level) ) {
93
-    		$this->logImpl($level, $message, $context);
94
-    	}
92
+        if( $this->levelHasReached($level) ) {
93
+            $this->logImpl($level, $message, $context);
94
+        }
95 95
     }
96 96
     
97 97
     protected function levelHasReached($level):bool
98 98
     {
99
-    	$result = true;
99
+        $result = true;
100 100
     	
101
-    	$orderedLevels = array(
102
-    			LogLevel::EMERGENCY => 0,
103
-    			LogLevel::ALERT => 1,
104
-    			LogLevel::CRITICAL => 2,
105
-    			LogLevel::ERROR => 3,
106
-    			LogLevel::WARNING => 4,
107
-    			LogLevel::NOTICE => 5,
108
-    			LogLevel::INFO => 6,
109
-    			LogLevel::DEBUG => 7
110
-    	);
101
+        $orderedLevels = array(
102
+                LogLevel::EMERGENCY => 0,
103
+                LogLevel::ALERT => 1,
104
+                LogLevel::CRITICAL => 2,
105
+                LogLevel::ERROR => 3,
106
+                LogLevel::WARNING => 4,
107
+                LogLevel::NOTICE => 5,
108
+                LogLevel::INFO => 6,
109
+                LogLevel::DEBUG => 7
110
+        );
111 111
     	
112
-    	if ( $this->level ) {
113
-    		$threshold = $orderedLevels[$this->level];
114
-    		$reached = $orderedLevels[$level];
115
-    		$result = $reached <= $threshold;
116
-    	}
112
+        if ( $this->level ) {
113
+            $threshold = $orderedLevels[$this->level];
114
+            $reached = $orderedLevels[$level];
115
+            $result = $reached <= $threshold;
116
+        }
117 117
     	
118
-    	return $result;
118
+        return $result;
119 119
     }
120 120
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
      */
90 90
     public function log($level, $message, array $context = array())
91 91
     {
92
-    	if( $this->levelHasReached($level) ) {
92
+    	if ($this->levelHasReached($level)) {
93 93
     		$this->logImpl($level, $message, $context);
94 94
     	}
95 95
     }
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
     			LogLevel::DEBUG => 7
110 110
     	);
111 111
     	
112
-    	if ( $this->level ) {
112
+    	if ($this->level) {
113 113
     		$threshold = $orderedLevels[$this->level];
114 114
     		$reached = $orderedLevels[$level];
115 115
     		$result = $reached <= $threshold;
Please login to merge, or discard this patch.
src/Generics/Socket/ServerSocket.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
     public function __construct(Endpoint $endpoint)
27 27
     {
28 28
         parent::__construct($endpoint);
29
-        if (! @socket_set_option($this->handle, SOL_SOCKET, SO_REUSEADDR, 1)) {
29
+        if (!@socket_set_option($this->handle, SOL_SOCKET, SO_REUSEADDR, 1)) {
30 30
             $code = socket_last_error($this->handle);
31 31
             throw new SocketException(socket_strerror($code), array(), $code);
32 32
         }
@@ -48,14 +48,14 @@  discard block
 block discarded – undo
48 48
         while ($runOn) {
49 49
             $clientHandle = @socket_accept($this->handle);
50 50
 
51
-            if (! is_resource($clientHandle)) {
51
+            if (!is_resource($clientHandle)) {
52 52
                 $code = socket_last_error($this->handle);
53 53
                 throw new SocketException(socket_strerror($code), array(), $code);
54 54
             }
55 55
 
56 56
             $address = null;
57 57
             $port = 0;
58
-            if (! @socket_getpeername($clientHandle, $address, $port)) {
58
+            if (!@socket_getpeername($clientHandle, $address, $port)) {
59 59
                 $code = socket_last_error($clientHandle);
60 60
                 throw new SocketException(socket_strerror($code), array(), $code);
61 61
             }
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
      */
74 74
     private function bind()
75 75
     {
76
-        if (! @socket_bind($this->handle, $this->endpoint->getAddress(), $this->endpoint->getPort())) {
76
+        if (!@socket_bind($this->handle, $this->endpoint->getAddress(), $this->endpoint->getPort())) {
77 77
             $code = socket_last_error($this->handle);
78 78
             throw new SocketException(socket_strerror($code), array(), $code);
79 79
         }
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
      */
87 87
     private function listen()
88 88
     {
89
-        if (! @socket_listen($this->handle, 5)) {
89
+        if (!@socket_listen($this->handle, 5)) {
90 90
             $code = socket_last_error($this->handle);
91 91
             throw new SocketException(socket_strerror($code), array(), $code);
92 92
         }
Please login to merge, or discard this patch.
src/Generics/Socket/Socket.php 3 patches
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -52,12 +52,12 @@  discard block
 block discarded – undo
52 52
      */
53 53
     private function open()
54 54
     {
55
-    	$this->handle = @socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
55
+        $this->handle = @socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
56 56
     	
57
-    	if (! is_resource($this->handle)) {
58
-    		$code = socket_last_error();
59
-    		throw new SocketException(socket_strerror($code), array(), $code);
60
-    	}
57
+        if (! is_resource($this->handle)) {
58
+            $code = socket_last_error();
59
+            throw new SocketException(socket_strerror($code), array(), $code);
60
+        }
61 61
     }
62 62
 
63 63
     /**
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
             $code = socket_last_error();
169 169
             if ($code != 0) {
170 170
                 if ($code != 10053) {
171
-                	throw new SocketException(socket_strerror($code), array(), $code);
171
+                    throw new SocketException(socket_strerror($code), array(), $code);
172 172
                 } else {
173 173
                     $this->handle = null;
174 174
                 }
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
      */
223 223
     public function isOpen()
224 224
     {
225
-    	return is_resource($this->handle);
225
+        return is_resource($this->handle);
226 226
     }
227 227
     
228 228
     /**
@@ -231,13 +231,13 @@  discard block
 block discarded – undo
231 231
      */
232 232
     public function reset()
233 233
     {
234
-    	try {
235
-	    	$this->close();
236
-	    	$this->open();
237
-    	}
238
-    	catch(Exception $ex)
239
-    	{
240
-    		throw new ResetException($ex->getMessage(), array(), $ex->getCode(), $ex);
241
-    	}
234
+        try {
235
+            $this->close();
236
+            $this->open();
237
+        }
238
+        catch(Exception $ex)
239
+        {
240
+            throw new ResetException($ex->getMessage(), array(), $ex->getCode(), $ex);
241
+        }
242 242
     }
243 243
 }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
     {
55 55
     	$this->handle = @socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
56 56
     	
57
-    	if (! is_resource($this->handle)) {
57
+    	if (!is_resource($this->handle)) {
58 58
     		$code = socket_last_error();
59 59
     		throw new SocketException(socket_strerror($code), array(), $code);
60 60
     	}
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
      */
87 87
     public function ready()
88 88
     {
89
-        if (! is_resource($this->handle)) {
89
+        if (!is_resource($this->handle)) {
90 90
             return false;
91 91
         }
92 92
 
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
             return false;
108 108
         }
109 109
 
110
-        if (! in_array($this->handle, $read)) {
110
+        if (!in_array($this->handle, $read)) {
111 111
             return false;
112 112
         }
113 113
 
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
      */
121 121
     public function isWriteable()
122 122
     {
123
-        if (! is_resource($this->handle)) {
123
+        if (!is_resource($this->handle)) {
124 124
             return false;
125 125
         }
126 126
 
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
             return false;
142 142
         }
143 143
 
144
-        if (! in_array($this->handle, $write)) {
144
+        if (!in_array($this->handle, $write)) {
145 145
             return false;
146 146
         }
147 147
 
@@ -235,7 +235,7 @@  discard block
 block discarded – undo
235 235
 	    	$this->close();
236 236
 	    	$this->open();
237 237
     	}
238
-    	catch(Exception $ex)
238
+    	catch (Exception $ex)
239 239
     	{
240 240
     		throw new ResetException($ex->getMessage(), array(), $ex->getCode(), $ex);
241 241
     	}
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -234,8 +234,7 @@
 block discarded – undo
234 234
     	try {
235 235
 	    	$this->close();
236 236
 	    	$this->open();
237
-    	}
238
-    	catch(Exception $ex)
237
+    	} catch(Exception $ex)
239 238
     	{
240 239
     		throw new ResetException($ex->getMessage(), array(), $ex->getCode(), $ex);
241 240
     	}
Please login to merge, or discard this patch.
src/Generics/Streams/FileInputStream.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
      */
170 170
     public function isLocked():bool
171 171
     {
172
-    	return $this->locked;
172
+        return $this->locked;
173 173
     }
174 174
 
175 175
     /**
@@ -188,6 +188,6 @@  discard block
 block discarded – undo
188 188
      */
189 189
     public function isOpen()
190 190
     {
191
-    	return is_resource($this->handle);
191
+        return is_resource($this->handle);
192 192
     }
193 193
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
      */
50 50
     public function __construct($file)
51 51
     {
52
-        if (! file_exists($file)) {
52
+        if (!file_exists($file)) {
53 53
             throw new FileNotFoundException("File {file} could not be found", array(
54 54
                 'file' => $file
55 55
             ));
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 
58 58
         $this->handle = fopen($file, "rb");
59 59
 
60
-        if (! $this->ready()) {
60
+        if (!$this->ready()) {
61 61
             throw new StreamException("Could not open {file} for reading", array(
62 62
                 'file' => $file
63 63
             ));
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
      */
99 99
     public function ready():bool
100 100
     {
101
-        return is_resource($this->handle) && ! feof($this->handle);
101
+        return is_resource($this->handle) && !feof($this->handle);
102 102
     }
103 103
 
104 104
     /**
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
      */
108 108
     public function read($length = 1, $offset = null):string
109 109
     {
110
-        if (! $this->ready()) {
110
+        if (!$this->ready()) {
111 111
             throw new StreamException("Stream is not ready!");
112 112
         }
113 113
 
Please login to merge, or discard this patch.
src/Generics/Streams/FileOutputStream.php 3 patches
Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -62,42 +62,42 @@  discard block
 block discarded – undo
62 62
      */
63 63
     public function __construct($file, $append = false)
64 64
     {
65
-    	$this->open($file, $append);
65
+        $this->open($file, $append);
66 66
     }
67 67
     
68 68
     private function open($file, $append)
69 69
     {
70
-    	$this->locked = false;
70
+        $this->locked = false;
71 71
     	
72
-    	$mode = "wb";
72
+        $mode = "wb";
73 73
     	
74
-    	if (file_exists($file)) {
75
-    		if (! $append) {
76
-    			throw new FileExistsException("File $file already exists!");
77
-    		}
74
+        if (file_exists($file)) {
75
+            if (! $append) {
76
+                throw new FileExistsException("File $file already exists!");
77
+            }
78 78
     		
79
-    		if (! is_writable($file)) {
80
-    			throw new NoAccessException("Cannot write to file $file");
81
-    		}
82
-    		$mode = "ab";
83
-    	} else {
84
-    		if (! is_writable(dirname($file))) {
85
-    			throw new NoAccessException("Cannot write to file {file}", array(
86
-    					'file' => $file
87
-    			));
88
-    		}
89
-    	}
79
+            if (! is_writable($file)) {
80
+                throw new NoAccessException("Cannot write to file $file");
81
+            }
82
+            $mode = "ab";
83
+        } else {
84
+            if (! is_writable(dirname($file))) {
85
+                throw new NoAccessException("Cannot write to file {file}", array(
86
+                        'file' => $file
87
+                ));
88
+            }
89
+        }
90 90
     	
91
-    	$this->handle = fopen($file, $mode);
91
+        $this->handle = fopen($file, $mode);
92 92
     	
93
-    	if (! $this->ready()) {
94
-    		throw new StreamException("Could not open {file} for writing", array(
95
-    				'file' => $file
96
-    		));
97
-    	}
93
+        if (! $this->ready()) {
94
+            throw new StreamException("Could not open {file} for writing", array(
95
+                    'file' => $file
96
+            ));
97
+        }
98 98
     	
99
-    	$this->fileName = $file;
100
-    	$this->append = $append;
99
+        $this->fileName = $file;
100
+        $this->append = $append;
101 101
     }
102 102
 
103 103
     /**
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
      */
239 239
     public function isLocked():bool
240 240
     {
241
-    	return $this->locked;
241
+        return $this->locked;
242 242
     }
243 243
 
244 244
     /**
@@ -247,22 +247,22 @@  discard block
 block discarded – undo
247 247
      */
248 248
     public function isOpen():bool
249 249
     {
250
-    	return is_resource($this->handle);
250
+        return is_resource($this->handle);
251 251
     }
252 252
     
253 253
     /**
254 254
      * {@inheritdoc}
255 255
      * @see \Generics\Resettable::reset()
256 256
      */
257
-	public function reset()
258
-	{
259
-		try {
260
-			$this->close();
261
-			$this->open($this->fileName, $this->append);
262
-		}
263
-		catch(Exception $ex)
264
-		{
265
-			throw new ResetException($ex->getMessage(), array(), $ex->getCode(), $ex);
266
-		}
267
-	}
257
+    public function reset()
258
+    {
259
+        try {
260
+            $this->close();
261
+            $this->open($this->fileName, $this->append);
262
+        }
263
+        catch(Exception $ex)
264
+        {
265
+            throw new ResetException($ex->getMessage(), array(), $ex->getCode(), $ex);
266
+        }
267
+    }
268 268
 }
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -72,16 +72,16 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 		}
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -259,8 +259,7 @@
 block discarded – undo
259 259
 		try {
260 260
 			$this->close();
261 261
 			$this->open($this->fileName, $this->append);
262
-		}
263
-		catch(Exception $ex)
262
+		} catch(Exception $ex)
264 263
 		{
265 264
 			throw new ResetException($ex->getMessage(), array(), $ex->getCode(), $ex);
266 265
 		}
Please login to merge, or discard this patch.
src/Generics/Util/Arrays.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -37,6 +37,6 @@
 block discarded – undo
37 37
      */
38 38
     public static function hasElement(array $array, $element):bool
39 39
     {
40
-    	return isset($array[$element]) && strlen($array[$element]) > 0;
40
+        return isset($array[$element]) && strlen($array[$element]) > 0;
41 41
     }
42 42
 }
Please login to merge, or discard this patch.
src/Generics/Socket/ClientSocket.php 2 patches
Indentation   +72 added lines, -72 removed lines patch added patch discarded remove patch
@@ -14,85 +14,85 @@
 block discarded – undo
14 14
  */
15 15
 class ClientSocket extends Socket {
16 16
 	
17
-	/**
18
-	 * Whether the socket is connected
19
-	 *
20
-	 * @var boolean
21
-	 */
22
-	private $conntected;
17
+    /**
18
+     * Whether the socket is connected
19
+     *
20
+     * @var boolean
21
+     */
22
+    private $conntected;
23 23
 	
24
-	/**
25
-	 * Create a new client socket
26
-	 *
27
-	 * @param Endpoint $endpoint
28
-	 *        	The endpoint to use
29
-	 * @param resource $clientHandle
30
-	 *        	optional existing client handle
31
-	 */
32
-	public function __construct(Endpoint $endpoint, $clientHandle = null) {
33
-		$this->endpoint = $endpoint;
34
-		$this->handle = $clientHandle;
35
-		$this->conntected = false;
24
+    /**
25
+     * Create a new client socket
26
+     *
27
+     * @param Endpoint $endpoint
28
+     *        	The endpoint to use
29
+     * @param resource $clientHandle
30
+     *        	optional existing client handle
31
+     */
32
+    public function __construct(Endpoint $endpoint, $clientHandle = null) {
33
+        $this->endpoint = $endpoint;
34
+        $this->handle = $clientHandle;
35
+        $this->conntected = false;
36 36
 		
37
-		if (! is_resource ( $clientHandle )) {
38
-			parent::__construct ( $endpoint );
39
-		}
40
-	}
37
+        if (! is_resource ( $clientHandle )) {
38
+            parent::__construct ( $endpoint );
39
+        }
40
+    }
41 41
 	
42
-	/**
43
-	 * Connect to remote endpoint
44
-	 *
45
-	 * @throws SocketException
46
-	 */
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 );
51
-		}
52
-		$this->conntected = true;
53
-	}
42
+    /**
43
+     * Connect to remote endpoint
44
+     *
45
+     * @throws SocketException
46
+     */
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 );
51
+        }
52
+        $this->conntected = true;
53
+    }
54 54
 	
55
-	/**
56
-	 * Disconnects the socket
57
-	 *
58
-	 * @throws SocketException
59
-	 */
60
-	public function disconnect() {
61
-		$this->close ();
62
-	}
55
+    /**
56
+     * Disconnects the socket
57
+     *
58
+     * @throws SocketException
59
+     */
60
+    public function disconnect() {
61
+        $this->close ();
62
+    }
63 63
 	
64
-	/**
65
-	 * Whether the client is connected
66
-	 *
67
-	 * @return boolean
68
-	 */
69
-	public function isConnected() {
70
-		return $this->conntected;
71
-	}
64
+    /**
65
+     * Whether the client is connected
66
+     *
67
+     * @return boolean
68
+     */
69
+    public function isConnected() {
70
+        return $this->conntected;
71
+    }
72 72
 	
73
-	/**
74
-	 *
75
-	 * @see \Generics\Socket\ClientSocket::disconnect()
76
-	 */
77
-	public function close() {
78
-		if (! $this->conntected) {
79
-			throw new SocketException ( "Socket is not connected" );
80
-		}
73
+    /**
74
+     *
75
+     * @see \Generics\Socket\ClientSocket::disconnect()
76
+     */
77
+    public function close() {
78
+        if (! $this->conntected) {
79
+            throw new SocketException ( "Socket is not connected" );
80
+        }
81 81
 		
82
-		parent::close ();
83
-		$this->conntected = false;
84
-	}
82
+        parent::close ();
83
+        $this->conntected = false;
84
+    }
85 85
 	
86
-	/**
87
-	 *
88
-	 * {@inheritdoc}
89
-	 * @see \Generics\Socket\Socket::isWriteable()
90
-	 */
91
-	public function isWriteable() {
92
-		if (! $this->isConnected ()) {
93
-			return false;
94
-		}
86
+    /**
87
+     *
88
+     * {@inheritdoc}
89
+     * @see \Generics\Socket\Socket::isWriteable()
90
+     */
91
+    public function isWriteable() {
92
+        if (! $this->isConnected ()) {
93
+            return false;
94
+        }
95 95
 		
96
-		return parent::isWriteable ();
97
-	}
96
+        return parent::isWriteable ();
97
+    }
98 98
 }
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -34,8 +34,8 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
src/Generics/Util/UrlParser.php 2 patches
Indentation   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -17,68 +17,68 @@
 block discarded – undo
17 17
  */
18 18
 class UrlParser {
19 19
 	
20
-	/**
21
-	 * Parse a URI into a Url
22
-	 *
23
-	 * @param string $url
24
-	 * @throws InvalidUrlException
25
-	 * @return \Generics\Socket\Url
26
-	 */
27
-	public static function parseUrl($url) {
28
-		$parts = parse_url ( $url );
20
+    /**
21
+     * Parse a URI into a Url
22
+     *
23
+     * @param string $url
24
+     * @throws InvalidUrlException
25
+     * @return \Generics\Socket\Url
26
+     */
27
+    public static function parseUrl($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' );
32
-		}
33
-		if (false === $parts || false === Arrays::hasElement ( $parts, 'scheme' )) {
34
-			throw new InvalidUrlException ( 'This URL does not contain a scheme part' );
35
-		}
30
+        if (false === $parts || false === Arrays::hasElement ( $parts, 'host' )) {
31
+            throw new InvalidUrlException ( 'This URL does not contain a host part' );
32
+        }
33
+        if (false === $parts || false === Arrays::hasElement ( $parts, 'scheme' )) {
34
+            throw new InvalidUrlException ( 'This URL does not contain a scheme part' );
35
+        }
36 36
 		
37
-		$address = $parts ['host'];
38
-		$scheme = $parts ['scheme'];
39
-		$port = 0;
40
-		$path = "/";
37
+        $address = $parts ['host'];
38
+        $scheme = $parts ['scheme'];
39
+        $port = 0;
40
+        $path = "/";
41 41
 		
42
-		if (isset ( $parts ['port'] )) {
43
-			$port = intval ( $parts ['port'] );
44
-		}
42
+        if (isset ( $parts ['port'] )) {
43
+            $port = intval ( $parts ['port'] );
44
+        }
45 45
 		
46
-		if ($port == 0) {
47
-			$port = self::getPortByScheme ( $scheme );
48
-		}
46
+        if ($port == 0) {
47
+            $port = self::getPortByScheme ( $scheme );
48
+        }
49 49
 		
50
-		if (isset ( $parts ['path'] )) {
51
-			$path = $parts ['path'];
52
-		}
50
+        if (isset ( $parts ['path'] )) {
51
+            $path = $parts ['path'];
52
+        }
53 53
 		
54
-		return new Url ( $address, $port, $path, $scheme );
55
-	}
54
+        return new Url ( $address, $port, $path, $scheme );
55
+    }
56 56
 	
57
-	/**
58
-	 * Get port number by scheme name.
59
-	 * The port will be the default which is defined by
60
-	 * http://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers
61
-	 *
62
-	 * @param string $scheme
63
-	 *        	The scheme.
64
-	 * @throws InvalidUrlException
65
-	 * @return int
66
-	 */
67
-	public static function getPortByScheme($scheme) {
68
-		switch ($scheme) {
69
-			case 'http' :
70
-				return 80;
57
+    /**
58
+     * Get port number by scheme name.
59
+     * The port will be the default which is defined by
60
+     * http://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers
61
+     *
62
+     * @param string $scheme
63
+     *        	The scheme.
64
+     * @throws InvalidUrlException
65
+     * @return int
66
+     */
67
+    public static function getPortByScheme($scheme) {
68
+        switch ($scheme) {
69
+            case 'http' :
70
+                return 80;
71 71
 			
72
-			case 'https' :
73
-				return 443;
72
+            case 'https' :
73
+                return 443;
74 74
 			
75
-			case 'ftp' :
76
-				return 21;
75
+            case 'ftp' :
76
+                return 21;
77 77
 			
78
-			default :
79
-				throw new InvalidUrlException ( "Scheme {scheme} is not handled!", array (
80
-						'scheme' => $scheme 
81
-				) );
82
-		}
83
-	}
78
+            default :
79
+                throw new InvalidUrlException ( "Scheme {scheme} is not handled!", array (
80
+                        'scheme' => $scheme 
81
+                ) );
82
+        }
83
+    }
84 84
 }
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -25,13 +25,13 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 }
Please login to merge, or discard this patch.