Completed
Push — master ( 5d4822...d1d02b )
by Maik
01:58
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/ClientSocket.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
         $this->handle = $clientHandle;
37 37
         $this->conntected = false;
38 38
 
39
-        if (! is_resource($clientHandle)) {
39
+        if (!is_resource($clientHandle)) {
40 40
             parent::__construct($endpoint);
41 41
         }
42 42
     }
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
      */
49 49
     public function connect()
50 50
     {
51
-        if (! @socket_connect($this->handle, $this->endpoint->getAddress(), $this->endpoint->getPort())) {
51
+        if (!@socket_connect($this->handle, $this->endpoint->getAddress(), $this->endpoint->getPort())) {
52 52
             $code = socket_last_error($this->handle);
53 53
             throw new SocketException(socket_strerror($code), array(), $code);
54 54
         }
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
      */
63 63
     public function disconnect()
64 64
     {
65
-        if (! $this->conntected) {
65
+        if (!$this->conntected) {
66 66
             throw new SocketException("Socket is not connected");
67 67
         }
68 68
 
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/Util/UrlParser.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -29,10 +29,10 @@
 block discarded – undo
29 29
     {
30 30
         $parts = parse_url($url);
31 31
 
32
-        if (! Arrays::hasElement($parts, 'host') ) {
32
+        if (!Arrays::hasElement($parts, 'host')) {
33 33
             throw new InvalidUrlException('This URL does not contain a host part');
34 34
         }
35
-        if (! Arrays::hasElement($parts, 'scheme') ) {
35
+        if (!Arrays::hasElement($parts, 'scheme')) {
36 36
             throw new InvalidUrlException('This URL does not contain a scheme part');
37 37
         }
38 38
 
Please login to merge, or discard this patch.