getSubject
Learn how to get the identified user ID.
This method provides the ID of the user the token identifies. When the token is anonymous, it returns null.
Signature
This method has the following signature:
public function getSubject(): ?stringThis method returns the identified user ID, or null when the token is anonymous.
Example
Here is a basic example of how to use this method:
<?phpuse Croct\Plug\Croct;
$croct = Croct::fromDotenv();$token = $croct->getUserToken();
$userId = $token->getSubject();