<commit_before><?php

class DrupalValetDriver extends ValetDriver
{
    /**
     * Determine if the driver serves the request.
     *
     * @param  string  $sitePath
     * @param  string  $siteName
     * @param  string  $uri
     * @return void
     */
    public function serves($sitePath, $siteName, $uri)
    {
        if (file_exists($sitePath.'/misc/drupal.js')) {
            return true;
        }
    }

    /**
     * Determine if the incoming request is for a static file.
     *
     * @param  string  $sitePath
     * @param  string  $siteName
     * @param  string  $uri
     * @return string|false
     */
    public function isStaticFile($sitePath, $siteName, $uri)
    {
        if (file_exists($sitePath.$uri) &&
            ! is_dir($sitePath.$uri) &&
            pathinfo($sitePath.$uri)['extension'] != 'php') {
            return $sitePath.$uri;
        }

        return false;
    }

    /**
     * Get the fully resolved path to the application's front controller.
     *
     * @param  string  $sitePath
     * @param  string  $siteName
     * @param  string  $uri
     * @return string
     */
    public function frontControllerPath($sitePath, $siteName, $uri)
    {
        chdir($sitePath);

        $_GET['q'] = $uri;
        $_SERVER['SCRIPT_FILENAME'] = $sitePath.'/index.php';
        $_SERVER['SCRIPT_NAME'] = '/index.php';

        return $sitePath.'/index.php';
    }
}<commit_msg>Implement more logic to handle Drupal 6, Drupal 7 and Drupal 8<commit_after><?php

class DrupalValetDriver extends ValetDriver
{
    /**
     * Determine if the driver serves the request.
     *
     * @param  string  $sitePath
     * @param  string  $siteName
     * @param  string  $uri
     * @return void
     */
    public function serves($sitePath, $siteName, $uri)
    {
      /**
       * /misc/drupal.js = Drupal 6 & 7
       * /core/lib/Drupal.php = Drupal 8
       */
      if (file_exists($sitePath.'/misc/drupal.js') ||
          file_exists($sitePath.'/core/lib/Drupal.php')) {
            return true;
        }
    }

    /**
     * Determine if the incoming request is for a static file.
     *
     * @param  string  $sitePath
     * @param  string  $siteName
     * @param  string  $uri
     * @return string|false
     */
    public function isStaticFile($sitePath, $siteName, $uri)
    {
        if (file_exists($sitePath.$uri) &&
            ! is_dir($sitePath.$uri) &&
            pathinfo($sitePath.$uri)['extension'] != 'php') {
            return $sitePath.$uri;
        }

        return false;
    }

    /**
     * Get the fully resolved path to the application's front controller.
     *
     * @param  string  $sitePath
     * @param  string  $siteName
     * @param  string  $uri
     * @return string
     */
    public function frontControllerPath($sitePath, $siteName, $uri)
    {
        if (!empty($uri) && $uri !== '/') {
            $_GET['q'] = $uri;
        }

        if (file_exists($sitePath.$uri) && ! is_dir($sitePath.$uri)) {
            chdir(dirname($sitePath.$uri));
            $_SERVER['SCRIPT_FILENAME'] = $sitePath.$uri;
            return $sitePath.$uri;
        } elseif (file_exists($frontControllerPath = $sitePath.$uri.'/index.php')) {
            chdir($sitePath.$uri);
            $_SERVER['SCRIPT_FILENAME'] = $sitePath.$uri.'/index.php';
            return $frontControllerPath;
        } else {
            chdir($sitePath);
            $_SERVER['SCRIPT_FILENAME'] = $sitePath.'/index.php';
            $_SERVER['SCRIPT_NAME'] = '/index.php';
            return $sitePath.'/index.php';
        }
    }
}
{'fraction_non_alphanumeric': 0.13967103429049346, 'fraction_numerical': 0.0016727069974909396, 'mean_word_length': 1.9530864197530864, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4125230', 'n_tokens_mistral': 1129, 'n_tokens_neox': 1104, 'n_words': 243}