protected function isNamespaceValid($namespace)
    {
        if ($namespace === '\\') {
            return true;
        }

        if (strpos($namespace, '\\') === 0) {
            $namespace = substr($namespace, 1);
        }

        $parts = explode('\\', $namespace);
        foreach ($parts as $part) {
            $match = preg_match(self::PATTERN_VALIDATE_NAMESPACE_NAME, $part);
            if ($match === false || $match <= 0 || ReservedKeywords::isReservedKeyword($part) !== false) {
                return false;
            }
        }

        return true;
    }