of

Learn how to create an API key from an identifier and a private key.

This method creates an API key from a UUID identifier and an optional private key.

Signature

This method has the following signature:

public static function of(string $identifier, ?string $privateKey = null): self

This method returns a new instance built from the given identifier and private key.

Example

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

<?phpuse Croct\Plug\ApiKey;
$apiKey = ApiKey::of('f47ac10b-58cc-4372-a567-0e02b2c3d479');

Parameters

The following list describes the supported parameters:

identifier
string

The public identifier of the key, as a UUID.

privateKey(optional)
string|null

The private key used to sign user tokens. When omitted, the key cannot sign tokens.

Default:null