$value) { $metricsList[] = $key . "/" . $value; } return [self::AGENT_HEADER_KEY => [\implode(" ", $metricsList)]]; } /** * Reads the gapic version string from a VERSION file. In order to determine the file * location, this method follows this procedure: * - accepts a class name $callingClass * - identifies the file defining that class * - searches up the directory structure for the 'src' directory * - looks in the directory above 'src' for a file named VERSION * * @param string $callingClass * @return string the gapic version * @throws \ReflectionException */ public static function readGapicVersionFromFile(string $callingClass) { $callingClassFile = (new \ReflectionClass($callingClass))->getFileName(); $versionFile = \substr($callingClassFile, 0, \strrpos($callingClassFile, \DIRECTORY_SEPARATOR . 'src' . \DIRECTORY_SEPARATOR)) . \DIRECTORY_SEPARATOR . 'VERSION'; return Version::readVersionFile($versionFile); } }