public static function bootstrap($coverageEnabled, $storageDirectory, $phpunitConfigFilePath = null)
    {
        Assert::boolean($coverageEnabled);
        if (!$coverageEnabled) {
            return function () {
                // do nothing - code coverage is not enabled
            };
        }

        $coverageGroup = isset($_GET[self::COVERAGE_GROUP_KEY]) ? $_GET[self::COVERAGE_GROUP_KEY] :
            (isset($_COOKIE[self::COVERAGE_GROUP_KEY]) ? $_COOKIE[self::COVERAGE_GROUP_KEY] : null);

        $storageDirectory .= ($coverageGroup ? '/' . $coverageGroup : '');

        if (isset($_GET[self::EXPORT_CODE_COVERAGE_KEY])) {
            header('Content-Type: text/plain');
            echo self::exportCoverageData($storageDirectory);
            exit;
        }

        $coverageId = isset($_GET[self::COVERAGE_ID_KEY]) ? $_GET[self::COVERAGE_ID_KEY] :
            (isset($_COOKIE[self::COVERAGE_ID_KEY]) ? $_COOKIE[self::COVERAGE_ID_KEY] : 'live-coverage');

        return LiveCodeCoverage::bootstrap(
            isset($_COOKIE[self::COLLECT_CODE_COVERAGE_KEY]) && (bool)$_COOKIE[self::COLLECT_CODE_COVERAGE_KEY],
            $storageDirectory,
            $phpunitConfigFilePath,
            $coverageId
        );
    }