File tree Expand file tree Collapse file tree 2 files changed +8
-4
lines changed
Expand file tree Collapse file tree 2 files changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -26,13 +26,13 @@ public function userId(int|string|null $id): static
2626 return $ this ;
2727 }
2828
29- public function getUserId (): string
29+ public function getUserId (): ? string
3030 {
3131 if ($ id = $ this ->get ($ this ->header ->userId )) {
3232 return $ id ;
3333 }
3434
35- return ' 0 ' ;
35+ return null ;
3636 }
3737
3838 public function ip (?string $ ip = null ): static
@@ -44,7 +44,7 @@ public function ip(?string $ip = null): static
4444 return $ this ;
4545 }
4646
47- public function getIp (): string
47+ public function getIp (): ? string
4848 {
4949 if ($ ip = $ this ->get ($ this ->header ->ip )) {
5050 return $ ip ;
@@ -88,6 +88,10 @@ public function getRequest(): Request
8888
8989 protected function set (string $ key , array |int |string |null $ value ): static
9090 {
91+ if (! is_int ($ value ) && ! $ value ) {
92+ return $ this ;
93+ }
94+
9195 if (is_int ($ value )) {
9296 $ value = (string ) $ value ;
9397 }
Original file line number Diff line number Diff line change 3131 // 4) getUserId() returns '0' when nothing present
3232 $ request = makeRequest ();
3333 $ telemetry = new TrackerRequest ($ request , $ header );
34- expect ($ telemetry ->getUserId ())->toBe ( ' 0 ' );
34+ expect ($ telemetry ->getUserId ())->toBeNull ( );
3535});
You can’t perform that action at this time.
0 commit comments