1919final class DSN
2020{
2121 private static $ PORTS = [
22- 'redis ' => 6379 ,
22+ 'redis ' => 6379 ,
2323 'mongodb ' => 27017 ,
24- 'tcp ' => 6379 ,
24+ 'tcp ' => 6379 ,
2525 ];
2626
2727 /**
28- * @type string
28+ * @var string
2929 */
3030 protected $ dsn ;
3131
3232 /**
33- * @type string
33+ * @var string
3434 */
3535 protected $ protocol ;
3636
3737 /**
38- * @type array
38+ * @var array
3939 */
4040 protected $ authentication ;
4141
4242 /**
43- * @type array
43+ * @var array
4444 */
4545 protected $ hosts ;
4646
4747 /**
48- * @type int
48+ * @var int
4949 */
5050 protected $ database ;
5151
5252 /**
53- * @type array
53+ * @var array
5454 */
5555 protected $ parameters = [];
5656
@@ -181,7 +181,7 @@ private function parseProtocol($dsn)
181181 private function parseDsn ($ dsn )
182182 {
183183 $ this ->parseProtocol ($ dsn );
184- if ($ this ->getProtocol () === null ) {
184+ if (null === $ this ->getProtocol ()) {
185185 return ;
186186 }
187187
@@ -191,10 +191,10 @@ private function parseDsn($dsn)
191191 // Parse and remove auth if they exist
192192 if (false !== $ pos = strrpos ($ dsn , '@ ' )) {
193193 $ temp = explode (': ' , str_replace ('\@ ' , '@ ' , substr ($ dsn , 0 , $ pos )));
194- $ dsn = substr ($ dsn , $ pos + 1 );
194+ $ dsn = substr ($ dsn , $ pos + 1 );
195195
196196 $ auth = [];
197- if (count ( $ temp ) === 2 ) {
197+ if (2 === count ( $ temp ) ) {
198198 $ auth ['username ' ] = $ temp [0 ];
199199 $ auth ['password ' ] = $ temp [1 ];
200200 } else {
@@ -204,8 +204,8 @@ private function parseDsn($dsn)
204204 $ this ->authentication = $ auth ;
205205 }
206206
207- if (strpos ($ dsn , '? ' ) !== false ) {
208- if (strpos ($ dsn , '/ ' ) === false ) {
207+ if (false !== strpos ($ dsn , '? ' )) {
208+ if (false === strpos ($ dsn , '/ ' )) {
209209 $ dsn = str_replace ('? ' , '/? ' , $ dsn );
210210 }
211211 }
@@ -214,8 +214,8 @@ private function parseDsn($dsn)
214214 $ this ->parseHosts ($ temp [0 ]);
215215
216216 if (isset ($ temp [1 ])) {
217- $ params = $ temp [1 ];
218- $ temp = explode ('? ' , $ params );
217+ $ params = $ temp [1 ];
218+ $ temp = explode ('? ' , $ params );
219219 $ this ->database = empty ($ temp [0 ]) ? null : $ temp [0 ];
220220 if (isset ($ temp [1 ])) {
221221 $ this ->parseParameters ($ temp [1 ]);
@@ -248,7 +248,7 @@ protected function parseParameters($params)
248248 $ parameters = explode ('& ' , $ params );
249249
250250 foreach ($ parameters as $ parameter ) {
251- $ kv = explode ('= ' , $ parameter , 2 );
251+ $ kv = explode ('= ' , $ parameter , 2 );
252252 $ this ->parameters [$ kv [0 ]] = isset ($ kv [1 ]) ? $ kv [1 ] : null ;
253253 }
254254
0 commit comments