in src/LegacyEventMapper.php [241:269]
private function ceResourceAndSubject(string $ceService, string $resource, ?string $domain): array
{
if (!array_key_exists($ceService, self::$ceResourceRegexMap)) {
return [$resource, null];
}
$ret = preg_match(self::$ceResourceRegexMap[$ceService], $resource, $matches);
if (!$ret) {
throw new RuntimeException(
$ret === 0 ? 'Resource regex did not match' : 'Failed while matching resource regex'
);
}
if (self::FIREBASE_DB_CE_SERVICE === $ceService) {
if (null === $domain) {
return [null, null];
}
$location = 'us-central1';
if ($domain !== 'firebaseio.com') {
preg_match('#^([\w-]+)\.#', $domain, $locationMatches);
if (!$locationMatches) {
return [null, null];
}
$location = $locationMatches[1];
}
return ["projects/_/locations/$location/$matches[1]", $matches[2]];
}
return [$matches[1], $matches[2]];
}