$metadata The metadata to update and return. * @return array The updated metadata. */ protected function applyServiceApiUsageMetrics($metadata) { if ($credType = $this->getCredType()) { // Add service api usage observability metrics info into metadata // We expect upstream libries to have the metadata key populated already $value = 'cred-type/' . $credType; if (!isset($metadata[self::$metricMetadataKey])) { // This case will happen only when someone invokes the updateMetadata // method on the credentials fetcher themselves. $metadata[self::$metricMetadataKey] = [$value]; } elseif (is_array($metadata[self::$metricMetadataKey])) { $metadata[self::$metricMetadataKey][0] .= ' ' . $value; } else { $metadata[self::$metricMetadataKey] .= ' ' . $value; } } return $metadata; } /** * @param array $metadata The metadata to update and return. * @param string $authRequestType The auth request type. Possible values are * `'at'`, `'it'`, `'mds'`. * @return array The updated metadata. */ protected function applyTokenEndpointMetrics($metadata, $authRequestType) { $metricsHeader = self::getMetricsHeader($this->getCredType(), $authRequestType); if (!isset($metadata[self::$metricMetadataKey])) { $metadata[self::$metricMetadataKey] = $metricsHeader; } return $metadata; } protected static function getVersion(): string { if (is_null(self::$version)) { $versionFilePath = __DIR__ . '/../VERSION'; self::$version = trim((string) file_get_contents($versionFilePath)); } return self::$version; } protected function getCredType(): string { return ''; } }