public static function getValidHooks($dir)
    {
        $composerFile = "{$dir}/composer.json";
        if (!file_exists($composerFile)) {
            return [];
        }

        $contents = file_get_contents($composerFile);
        $json = json_decode($contents, true);
        $hooks = array_merge(
            isset($json['scripts']) ? $json['scripts'] : [],
            isset($json['hooks']) ? $json['hooks'] : [],
            isset($json['extra']['hooks']) ? $json['extra']['hooks'] : []
        );
        $validHooks = [];

        foreach ($hooks as $hook => $script) {
            if (self::isValidHook($hook)) {
                $validHooks[$hook] = $script;
            }
        }

        return $validHooks;
    }