File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2222
2323class HttpAuth implements \JsonSerializable
2424{
25- private const FIELD_USERNAME = 'username ' ;
26- private const FIELD_PASSWORD = 'password ' ;
27-
28- public string $ username = '' ;
29- public string $ password = '' ;
25+ public string $ username ;
26+ public string $ password ;
3027
3128 public function __construct (string $ username = '' , string $ password = '' )
3229 {
@@ -49,18 +46,23 @@ public function compileAuthString(): string
4946 return (string )$ this ;
5047 }
5148
52- public function jsonSerialize (): array
49+ public function jsonSerialize (): \ stdClass
5350 {
54- return [self ::FIELD_USERNAME => $ this ->username , self ::FIELD_PASSWORD => $ this ->password ];
51+ $ out = new \stdClass ();
52+ $ out ->username = $ this ->username ;
53+ if ('' !== $ this ->password ) {
54+ $ out ->password = $ this ->password ;
55+ }
56+ return $ out ;
5557 }
5658
5759 public function __debugInfo (): array
5860 {
59- return [self :: FIELD_USERNAME => $ this ->username ];
61+ return [' username ' => $ this ->username ];
6062 }
6163
6264 public function __toString (): string
6365 {
64- return trim ( sprintf ( ' %s:%s ' , $ this ->username , $ this ->password ), ' : ' ) ;
66+ return $ this -> password !== '' ? "{ $ this ->username } : { $ this ->password }" : $ this -> username ;
6567 }
6668}
You can’t perform that action at this time.
0 commit comments