@@ -191,7 +191,7 @@ public function ssl(bool $use_ssl = false): self
191
191
*/
192
192
public function port (int $ port = 5222 ): self
193
193
{
194
- $ this ->port = ($ port ) ? $ port : 5222 ;
194
+ $ this ->port = ($ port > 0 ) ? $ port : 5222 ;
195
195
196
196
// Change port if we use SSL
197
197
if ($ this ->port == 5222 && $ this ->use_ssl )
@@ -210,14 +210,14 @@ public function port(int $port = 5222): self
210
210
*/
211
211
public function username (string $ username = '' ): self
212
212
{
213
- if (strpos ($ username , '@ ' ) === false )
213
+ if (str_contains ($ username , '@ ' ))
214
214
{
215
- $ this ->username = $ username ;
215
+ $ this ->jid = explode ('@ ' , $ username , 2 );
216
+ $ this ->username = $ this ->jid [0 ];
216
217
}
217
218
else
218
219
{
219
- $ this ->jid = explode ('@ ' , $ username , 2 );
220
- $ this ->username = $ this ->jid [0 ];
220
+ $ this ->username = $ username ;
221
221
}
222
222
223
223
return $ this ;
@@ -232,7 +232,7 @@ public function username(string $username = ''): self
232
232
*/
233
233
public function server (string $ server = '' ): self
234
234
{
235
- $ this ->connect_server = ( $ server) ? $ server : 'localhost ' ;
235
+ $ this ->connect_server = $ server ? : 'localhost ' ;
236
236
$ this ->server = $ this ->jid [1 ] ?? $ this ->connect_server ;
237
237
238
238
return $ this ;
@@ -407,7 +407,7 @@ public function to(string $address, string $realname = ''): void
407
407
}
408
408
409
409
/**
410
- * {@inheritDoc}
410
+ * Resets all the data (address, template file, etc) to default
411
411
*/
412
412
public function reset (): void
413
413
{
@@ -663,7 +663,7 @@ public function listen(int $timeout = 10, bool $wait = false): bool|array
663
663
}
664
664
665
665
/**
666
- * Initiates account registration (based on data used for contructor )
666
+ * Initiates account registration (based on data used for constructor )
667
667
*
668
668
* @return bool|null
669
669
*/
@@ -714,7 +714,7 @@ function send_presence(string $message = '', string $type = '', bool $unavailabl
714
714
*/
715
715
function response (array $ xml ): bool
716
716
{
717
- if (!is_array ( $ xml ) || ! count ($ xml ))
717
+ if (!count ($ xml ))
718
718
{
719
719
return false ;
720
720
}
0 commit comments