hasPrivateKey

Learn how to check whether the API key can sign user tokens.

This method reports whether the API key carries a private key for signing user tokens.

Signature

This method has the following signature:

public function hasPrivateKey(): bool

This method returns true when the key carries a private key for signing user tokens, and false otherwise.

Example

Here is a basic example of how to use this method:

<?phpuse Croct\Plug\ApiKey;
$apiKey = ApiKey::parse('f47ac10b-58cc-4372-a567-0e02b2c3d479');
if ($apiKey->hasPrivateKey()) {    // The key can sign user tokens.}