ProviderMetadata::__construct( string $id, string $name, WordPressAiClientProvidersEnumsProviderTypeEnum $type, string|null $credentialsUrl = null, WordPressAiClientProvidersHttpEnumsRequestAuthenticationMethod|null $authenticationMethod = null, string|null $description = null, string|null $logoPath = null )

In this article

Constructor.

Parameters

$idstringrequired
The provider’s unique identifier.
$namestringrequired
The provider’s display name.
$typeWordPressAiClientProvidersEnumsProviderTypeEnumrequired
The provider type.
$credentialsUrlstring|nulloptional
The URL where users can get credentials.

Default:null

$authenticationMethodWordPressAiClientProvidersHttpEnumsRequestAuthenticationMethod|nulloptional
The authentication method.

Default:null

$descriptionstring|nulloptional
The provider’s description.

Default:null

$logoPathstring|nulloptional
The full path to the provider’s logo image file.

Default:null

Source

public function __construct(string $id, string $name, ProviderTypeEnum $type, ?string $credentialsUrl = null, ?RequestAuthenticationMethod $authenticationMethod = null, ?string $description = null, ?string $logoPath = null)
{
    if (!preg_match('/^[a-z0-9\-_]+$/', $id)) {
        throw new InvalidArgumentException(sprintf(
            // phpcs:ignore Generic.Files.LineLength.TooLong
            'Invalid provider ID "%s". Only lowercase alphanumeric characters, hyphens, and underscores are allowed.',
            $id
        ));
    }
    $this->id = $id;
    $this->name = $name;
    $this->description = $description;
    $this->type = $type;
    $this->credentialsUrl = $credentialsUrl;
    $this->authenticationMethod = $authenticationMethod;
    $this->logoPath = $logoPath;
}

Changelog

VersionDescription
1.3.0Added optional $logoPath parameter.
1.2.0Added optional $description parameter.
0.1.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.