Google\Cloud\Datastore\Key::determineIdentifierType PHP Method

determineIdentifierType() private method

Determine whether the given identifier is an ID or a Name
private determineIdentifierType ( mixed $identifier, string | null $identifierType ) : string
$identifier mixed The given value.
$identifierType string | null If not null and allowed, this will be used as the type. If null, type will be inferred.
return string
    private function determineIdentifierType($identifier, $identifierType)
    {
        $allowedTypes = [self::TYPE_ID, self::TYPE_NAME];
        if (!is_null($identifierType) && in_array($identifierType, $allowedTypes)) {
            return $identifierType;
        } elseif (!is_null($identifierType)) {
            throw new InvalidArgumentException(sprintf('Invalid identifier type %s', $identifierType));
        }
        if (is_numeric($identifier)) {
            return self::TYPE_ID;
        }
        return self::TYPE_NAME;
    }