Google Apps Events Subscriptions V1 Client - Class SubscriptionsServiceClient (0.1.5)

Reference documentation and code samples for the Google Apps Events Subscriptions V1 Client class SubscriptionsServiceClient.

Service Description: A service that manages subscriptions to Google Workspace events.

This class provides the ability to make remote calls to the backing service through method calls that map to API methods.

Many parameters require resource names to be formatted in a particular way. To assist with these names, this class includes a format method for each type of name, and additionally a parseName method to extract the individual identifiers contained within formatted names that are returned by the API.

Namespace

Google \ Apps \ Events \ Subscriptions \ V1 \ Client

Methods

__construct

Constructor.

Parameters
Name Description
options array

Optional. Options for configuring the service API wrapper.

↳ apiEndpoint string

The address of the API remote host. May optionally include the port, formatted as "

↳ credentials string|array|FetchAuthTokenInterface|CredentialsWrapper

The credentials to be used by the client to authorize API calls. This option accepts either a path to a credentials file, or a decoded credentials file as a PHP array. Advanced usage: In addition, this option can also accept a pre-constructed Google\Auth\FetchAuthTokenInterface object or Google\ApiCore\CredentialsWrapper object. Note that when one of these objects are provided, any settings in $credentialsConfig will be ignored.

↳ credentialsConfig array

Options used to configure credentials, including auth token caching, for the client. For a full list of supporting configuration options, see Google\ApiCore\CredentialsWrapper::build() .

↳ disableRetries bool

Determines whether or not retries defined by the client configuration should be disabled. Defaults to false.

↳ clientConfig string|array

Client method configuration, including retry settings. This option can be either a path to a JSON file, or a PHP array containing the decoded JSON data. By default this settings points to the default client config file, which is provided in the resources folder.

↳ transport string|TransportInterface

The transport used for executing network requests. May be either the string rest or grpc. Defaults to grpc if gRPC support is detected on the system. Advanced usage: Additionally, it is possible to pass in an already instantiated Google\ApiCore\Transport\TransportInterface object. Note that when this object is provided, any settings in $transportConfig, and any $apiEndpoint setting, will be ignored.

↳ transportConfig array

Configuration options that will be used to construct the transport. Options for each supported transport type should be passed in a key for that transport. For example: $transportConfig = [ 'grpc' => [...], 'rest' => [...], ]; See the Google\ApiCore\Transport\GrpcTransport::build() and Google\ApiCore\Transport\RestTransport::build() methods for the supported options.

↳ clientCertSource callable

A callable which returns the client cert as a string. This can be used to provide a certificate and private key to the transport layer for mTLS.

↳ logger false|LoggerInterface

A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the 'GOOGLE_SDK_PHP_LOGGING' environment flag

createSubscription

Creates a Google Workspace subscription. To learn how to use this method, see Create a Google Workspace subscription.

The async variant is SubscriptionsServiceClient::createSubscriptionAsync() .

Parameters
Name Description
request Google\Apps\Events\Subscriptions\V1\CreateSubscriptionRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\ApiCore\OperationResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Apps\Events\Subscriptions\V1\Client\SubscriptionsServiceClient;
use Google\Apps\Events\Subscriptions\V1\CreateSubscriptionRequest;
use Google\Apps\Events\Subscriptions\V1\NotificationEndpoint;
use Google\Apps\Events\Subscriptions\V1\Subscription;
use Google\Rpc\Status;

/**
 * @param string $subscriptionTargetResource    Immutable. The Google Workspace resource that's monitored for
 *                                              events, formatted as the [full resource
 *                                              name](https://google.aip.dev/122#full-resource-names). To learn about
 *                                              target resources and the events that they support, see [Supported Google
 *                                              Workspace
 *                                              events](https://developers.google.com/workspace/events#supported-events).
 *
 *                                              A user can only authorize your app to create one subscription for a given
 *                                              target resource. If your app tries to create another subscription with the
 *                                              same user credentials, the request returns an `ALREADY_EXISTS` error.
 * @param string $subscriptionEventTypesElement Immutable. Unordered list. Input for creating a subscription.
 *                                              Otherwise, output only. One or more types of events to receive about the
 *                                              target resource. Formatted according to the CloudEvents specification.
 *
 *                                              The supported event types depend on the target resource of your
 *                                              subscription. For details, see [Supported Google Workspace
 *                                              events](https://developers.google.com/workspace/events/guides#supported-events).
 *
 *                                              By default, you also receive events about the [lifecycle of your
 *                                              subscription](https://developers.google.com/workspace/events/guides/events-lifecycle).
 *                                              You don't need to specify lifecycle events for this field.
 *
 *                                              If you specify an event type that doesn't exist for the target resource,
 *                                              the request returns an HTTP `400 Bad Request` status code.
 */
function create_subscription_sample(
    string $subscriptionTargetResource,
    string $subscriptionEventTypesElement
): void {
    // Create a client.
    $subscriptionsServiceClient = new SubscriptionsServiceClient();

    // Prepare the request message.
    $subscriptionEventTypes = [$subscriptionEventTypesElement,];
    $subscriptionNotificationEndpoint = new NotificationEndpoint();
    $subscription = (new Subscription())
        ->setTargetResource($subscriptionTargetResource)
        ->setEventTypes($subscriptionEventTypes)
        ->setNotificationEndpoint($subscriptionNotificationEndpoint);
    $request = (new CreateSubscriptionRequest())
        ->setSubscription($subscription);

    // Call the API and handle any network failures.
    try {
        /** @var OperationResponse $response */
        $response = $subscriptionsServiceClient->createSubscription($request);
        $response->pollUntilComplete();

        if ($response->operationSucceeded()) {
            /** @var Subscription $result */
            $result = $response->getResult();
            printf('Operation successful with response data: %s' . PHP_EOL, $result->serializeToJsonString());
        } else {
            /** @var Status $error */
            $error = $response->getError();
            printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString());
        }
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $subscriptionTargetResource = '[TARGET_RESOURCE]';
    $subscriptionEventTypesElement = '[EVENT_TYPES]';

    create_subscription_sample($subscriptionTargetResource, $subscriptionEventTypesElement);
}

deleteSubscription

Deletes a Google Workspace subscription.

To learn how to use this method, see Delete a Google Workspace subscription.

The async variant is SubscriptionsServiceClient::deleteSubscriptionAsync() .

Parameters
Name Description
request Google\Apps\Events\Subscriptions\V1\DeleteSubscriptionRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\ApiCore\OperationResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Apps\Events\Subscriptions\V1\Client\SubscriptionsServiceClient;
use Google\Apps\Events\Subscriptions\V1\DeleteSubscriptionRequest;
use Google\Rpc\Status;

/**
 * @param string $formattedName Resource name of the subscription to delete.
 *
 *                              Format: `subscriptions/{subscription}`
 *                              Please see {@see SubscriptionsServiceClient::subscriptionName()} for help formatting this field.
 */
function delete_subscription_sample(string $formattedName): void
{
    // Create a client.
    $subscriptionsServiceClient = new SubscriptionsServiceClient();

    // Prepare the request message.
    $request = (new DeleteSubscriptionRequest())
        ->setName($formattedName);

    // Call the API and handle any network failures.
    try {
        /** @var OperationResponse $response */
        $response = $subscriptionsServiceClient->deleteSubscription($request);
        $response->pollUntilComplete();

        if ($response->operationSucceeded()) {
            printf('Operation completed successfully.' . PHP_EOL);
        } else {
            /** @var Status $error */
            $error = $response->getError();
            printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString());
        }
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedName = SubscriptionsServiceClient::subscriptionName('[SUBSCRIPTION]');

    delete_subscription_sample($formattedName);
}

getSubscription

Gets details about a Google Workspace subscription. To learn how to use this method, see Get details about a Google Workspace subscription.

The async variant is SubscriptionsServiceClient::getSubscriptionAsync() .

Parameters
Name Description
request Google\Apps\Events\Subscriptions\V1\GetSubscriptionRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\Apps\Events\Subscriptions\V1\Subscription
Example
use Google\ApiCore\ApiException;
use Google\Apps\Events\Subscriptions\V1\Client\SubscriptionsServiceClient;
use Google\Apps\Events\Subscriptions\V1\GetSubscriptionRequest;
use Google\Apps\Events\Subscriptions\V1\Subscription;

/**
 * @param string $formattedName Resource name of the subscription.
 *
 *                              Format: `subscriptions/{subscription}`
 *                              Please see {@see SubscriptionsServiceClient::subscriptionName()} for help formatting this field.
 */
function get_subscription_sample(string $formattedName): void
{
    // Create a client.
    $subscriptionsServiceClient = new SubscriptionsServiceClient();

    // Prepare the request message.
    $request = (new GetSubscriptionRequest())
        ->setName($formattedName);

    // Call the API and handle any network failures.
    try {
        /** @var Subscription $response */
        $response = $subscriptionsServiceClient->getSubscription($request);
        printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedName = SubscriptionsServiceClient::subscriptionName('[SUBSCRIPTION]');

    get_subscription_sample($formattedName);
}

listSubscriptions

Lists Google Workspace subscriptions. To learn how to use this method, see List Google Workspace subscriptions.

The async variant is SubscriptionsServiceClient::listSubscriptionsAsync() .

Parameters
Name Description
request Google\Apps\Events\Subscriptions\V1\ListSubscriptionsRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\ApiCore\PagedListResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Apps\Events\Subscriptions\V1\Client\SubscriptionsServiceClient;
use Google\Apps\Events\Subscriptions\V1\ListSubscriptionsRequest;
use Google\Apps\Events\Subscriptions\V1\Subscription;

/**
 * @param string $filter A query filter.
 *
 *                       You can filter subscriptions by event type (`event_types`)
 *                       and target resource (`target_resource`).
 *
 *                       You must specify at least one event type in your query. To filter for
 *                       multiple event types, use the `OR` operator.
 *
 *                       To filter by both event type and target resource, use the `AND` operator
 *                       and specify the full resource name, such as
 *                       `//chat.googleapis.com/spaces/{space}`.
 *
 *                       For example, the following queries are valid:
 *
 *                       ```
 *                       event_types:"google.workspace.chat.membership.v1.updated" OR
 *                       event_types:"google.workspace.chat.message.v1.created"
 *
 *                       event_types:"google.workspace.chat.message.v1.created" AND
 *                       target_resource="//chat.googleapis.com/spaces/{space}"
 *
 *                       ( event_types:"google.workspace.chat.membership.v1.updated" OR
 *                       event_types:"google.workspace.chat.message.v1.created" ) AND
 *                       target_resource="//chat.googleapis.com/spaces/{space}"
 *                       ```
 *
 *                       The server rejects invalid queries with an `INVALID_ARGUMENT`
 *                       error.
 */
function list_subscriptions_sample(string $filter): void
{
    // Create a client.
    $subscriptionsServiceClient = new SubscriptionsServiceClient();

    // Prepare the request message.
    $request = (new ListSubscriptionsRequest())
        ->setFilter($filter);

    // Call the API and handle any network failures.
    try {
        /** @var PagedListResponse $response */
        $response = $subscriptionsServiceClient->listSubscriptions($request);

        /** @var Subscription $element */
        foreach ($response as $element) {
            printf('Element data: %s' . PHP_EOL, $element->serializeToJsonString());
        }
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $filter = '[FILTER]';

    list_subscriptions_sample($filter);
}

reactivateSubscription

Reactivates a suspended Google Workspace subscription.

This method resets your subscription's State field to ACTIVE. Before you use this method, you must fix the error that suspended the subscription. To learn how to use this method, see Reactivate a Google Workspace subscription.

The async variant is SubscriptionsServiceClient::reactivateSubscriptionAsync() .

Parameters
Name Description
request Google\Apps\Events\Subscriptions\V1\ReactivateSubscriptionRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\ApiCore\OperationResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Apps\Events\Subscriptions\V1\Client\SubscriptionsServiceClient;
use Google\Apps\Events\Subscriptions\V1\ReactivateSubscriptionRequest;
use Google\Apps\Events\Subscriptions\V1\Subscription;
use Google\Rpc\Status;

/**
 * @param string $formattedName Resource name of the subscription.
 *
 *                              Format: `subscriptions/{subscription}`
 *                              Please see {@see SubscriptionsServiceClient::subscriptionName()} for help formatting this field.
 */
function reactivate_subscription_sample(string $formattedName): void
{
    // Create a client.
    $subscriptionsServiceClient = new SubscriptionsServiceClient();

    // Prepare the request message.
    $request = (new ReactivateSubscriptionRequest())
        ->setName($formattedName);

    // Call the API and handle any network failures.
    try {
        /** @var OperationResponse $response */
        $response = $subscriptionsServiceClient->reactivateSubscription($request);
        $response->pollUntilComplete();

        if ($response->operationSucceeded()) {
            /** @var Subscription $result */
            $result = $response->getResult();
            printf('Operation successful with response data: %s' . PHP_EOL, $result->serializeToJsonString());
        } else {
            /** @var Status $error */
            $error = $response->getError();
            printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString());
        }
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedName = SubscriptionsServiceClient::subscriptionName('[SUBSCRIPTION]');

    reactivate_subscription_sample($formattedName);
}

updateSubscription

Updates or renews a Google Workspace subscription. To learn how to use this method, see Update or renew a Google Workspace subscription.

The async variant is SubscriptionsServiceClient::updateSubscriptionAsync() .

Parameters
Name Description
request Google\Apps\Events\Subscriptions\V1\UpdateSubscriptionRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\ApiCore\OperationResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Apps\Events\Subscriptions\V1\Client\SubscriptionsServiceClient;
use Google\Apps\Events\Subscriptions\V1\NotificationEndpoint;
use Google\Apps\Events\Subscriptions\V1\Subscription;
use Google\Apps\Events\Subscriptions\V1\UpdateSubscriptionRequest;
use Google\Rpc\Status;

/**
 * @param string $subscriptionTargetResource    Immutable. The Google Workspace resource that's monitored for
 *                                              events, formatted as the [full resource
 *                                              name](https://google.aip.dev/122#full-resource-names). To learn about
 *                                              target resources and the events that they support, see [Supported Google
 *                                              Workspace
 *                                              events](https://developers.google.com/workspace/events#supported-events).
 *
 *                                              A user can only authorize your app to create one subscription for a given
 *                                              target resource. If your app tries to create another subscription with the
 *                                              same user credentials, the request returns an `ALREADY_EXISTS` error.
 * @param string $subscriptionEventTypesElement Immutable. Unordered list. Input for creating a subscription.
 *                                              Otherwise, output only. One or more types of events to receive about the
 *                                              target resource. Formatted according to the CloudEvents specification.
 *
 *                                              The supported event types depend on the target resource of your
 *                                              subscription. For details, see [Supported Google Workspace
 *                                              events](https://developers.google.com/workspace/events/guides#supported-events).
 *
 *                                              By default, you also receive events about the [lifecycle of your
 *                                              subscription](https://developers.google.com/workspace/events/guides/events-lifecycle).
 *                                              You don't need to specify lifecycle events for this field.
 *
 *                                              If you specify an event type that doesn't exist for the target resource,
 *                                              the request returns an HTTP `400 Bad Request` status code.
 */
function update_subscription_sample(
    string $subscriptionTargetResource,
    string $subscriptionEventTypesElement
): void {
    // Create a client.
    $subscriptionsServiceClient = new SubscriptionsServiceClient();

    // Prepare the request message.
    $subscriptionEventTypes = [$subscriptionEventTypesElement,];
    $subscriptionNotificationEndpoint = new NotificationEndpoint();
    $subscription = (new Subscription())
        ->setTargetResource($subscriptionTargetResource)
        ->setEventTypes($subscriptionEventTypes)
        ->setNotificationEndpoint($subscriptionNotificationEndpoint);
    $request = (new UpdateSubscriptionRequest())
        ->setSubscription($subscription);

    // Call the API and handle any network failures.
    try {
        /** @var OperationResponse $response */
        $response = $subscriptionsServiceClient->updateSubscription($request);
        $response->pollUntilComplete();

        if ($response->operationSucceeded()) {
            /** @var Subscription $result */
            $result = $response->getResult();
            printf('Operation successful with response data: %s' . PHP_EOL, $result->serializeToJsonString());
        } else {
            /** @var Status $error */
            $error = $response->getError();
            printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString());
        }
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $subscriptionTargetResource = '[TARGET_RESOURCE]';
    $subscriptionEventTypesElement = '[EVENT_TYPES]';

    update_subscription_sample($subscriptionTargetResource, $subscriptionEventTypesElement);
}

createSubscriptionAsync

Parameters
Name Description
request Google\Apps\Events\Subscriptions\V1\CreateSubscriptionRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\OperationResponse>

deleteSubscriptionAsync

Parameters
Name Description
request Google\Apps\Events\Subscriptions\V1\DeleteSubscriptionRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\OperationResponse>

getSubscriptionAsync

Parameters
Name Description
request Google\Apps\Events\Subscriptions\V1\GetSubscriptionRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Apps\Events\Subscriptions\V1\Subscription>

listSubscriptionsAsync

Parameters
Name Description
request Google\Apps\Events\Subscriptions\V1\ListSubscriptionsRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\PagedListResponse>

reactivateSubscriptionAsync

Parameters
Name Description
request Google\Apps\Events\Subscriptions\V1\ReactivateSubscriptionRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\OperationResponse>

updateSubscriptionAsync

Parameters
Name Description
request Google\Apps\Events\Subscriptions\V1\UpdateSubscriptionRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\OperationResponse>

getOperationsClient

Return an OperationsClient object with the same endpoint as $this.

Returns
Type Description
Google\LongRunning\Client\OperationsClient

resumeOperation

Resume an existing long running operation that was previously started by a long running API method. If $methodName is not provided, or does not match a long running API method, then the operation can still be resumed, but the OperationResponse object will not deserialize the final response.

Parameters
Name Description
operationName string

The name of the long running operation

methodName string

The name of the method used to start the operation

Returns
Type Description
Google\ApiCore\OperationResponse

static::subscriptionName

Formats a string containing the fully-qualified path to represent a subscription resource.

Parameter
Name Description
subscription string
Returns
Type Description
string The formatted subscription resource.

static::topicName

Formats a string containing the fully-qualified path to represent a topic resource.

Parameters
Name Description
project string
topic string
Returns
Type Description
string The formatted topic resource.

static::userName

Formats a string containing the fully-qualified path to represent a user resource.

Parameter
Name Description
user string
Returns
Type Description
string The formatted user resource.

static::parseName

Parses a formatted name string and returns an associative array of the components in the name.

The following name formats are supported: Template: Pattern

  • subscription: subscriptions/{subscription}
  • topic: projects/{project}/topics/{topic}
  • user: users/{user}

The optional $template argument can be supplied to specify a particular pattern, and must match one of the templates listed above. If no $template argument is provided, or if the $template argument does not match one of the templates listed, then parseName will check each of the supported templates, and return the first match.

Parameters
Name Description
formattedName string

The formatted name string

template ?string

Optional name of template to match

Returns
Type Description
array An associative array from name component IDs to component values.