<commit_before><?php
/**
 * MediaWiki IDProvider Extension
 *
 * Provides (unique) IDs using different ID algorithms.
 *
 * @link https://github.com/gesinn-it/IDProvider
 *
 * @author <EMAIL> GmbH & Co. KG
 * @license MIT
 */

namespace MediaWiki\Extension\IdProvider;

use MediaWiki\Extension\IdProvider\Generators\FakeIdGenerator;
use MediaWiki\Extension\IdProvider\Generators\IncrementIdGenerator;
use MediaWiki\Extension\IdProvider\Generators\UuidGenerator;
use MediaWiki\MediaWikiServices;
use MWException;
use Title;
use WikiPage;

class IdProviderFactory {

	public static function increment( array $params = [] ) {
		$prefix = self::paramGet( $params, 'prefix', '' );
		$padding = self::paramGet( $params, 'padding', 1 );

		$generator = new IncrementIdGenerator( self::dbExecute(), $prefix, $padding );

		return self::provider( $generator );
	}

	public static function random( array $params = [] ) {
		$type = self::paramGet( $params, 'type', 'uuid' );
		$generator = $type === 'fakeid' ? ( new FakeIdGenerator ) : ( new UuidGenerator );

		return self::provider( $generator );
	}

	private static function provider( $generator ) {
		return new IdProvider( $generator, self::isUniqueId() );
	}

	private static function dbExecute() {
		return function ( $action ) {
			$factory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
			$mainLB = $factory->getMainLB();
			$dbw = $mainLB->getConnectionRef( DB_MASTER );
			$factory->beginMasterChanges( __METHOD__ );
			$result = $action( $dbw );
			$factory->commitMasterChanges( __METHOD__ );

			return $result;<commit_msg>Updated function calls in IdProviderFactory to new versions  (#14)<commit_after><?php
/**
 * MediaWiki IDProvider Extension
 *
 * Provides (unique) IDs using different ID algorithms.
 *
 * @link https://github.com/gesinn-it/IDProvider
 *
 * @author <EMAIL> & Co. KG
 * @license MIT
 */

namespace MediaWiki\Extension\IdProvider;

use MediaWiki\Extension\IdProvider\Generators\FakeIdGenerator;
use MediaWiki\Extension\IdProvider\Generators\IncrementIdGenerator;
use MediaWiki\Extension\IdProvider\Generators\UuidGenerator;
use MediaWiki\MediaWikiServices;
use MWException;
use Title;
use WikiPage;

class IdProviderFactory {

	public static function increment( array $params = [] ) {
		$prefix = self::paramGet( $params, 'prefix', '' );
		$padding = self::paramGet( $params, 'padding', 1 );

		$generator = new IncrementIdGenerator( self::dbExecute(), $prefix, $padding );

		return self::provider( $generator );
	}

	public static function random( array $params = [] ) {
		$type = self::paramGet( $params, 'type', 'uuid' );
		$generator = $type === 'fakeid' ? ( new FakeIdGenerator ) : ( new UuidGenerator );

		return self::provider( $generator );
	}

	private static function provider( $generator ) {
		return new IdProvider( $generator, self::isUniqueId() );
	}

	private static function dbExecute() {
		return function ( $action ) {
			global $wgVersion;
			$factory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
			$mainLB = $factory->getMainLB();
			if ( version_compare( $wgVersion, '1.37', '<' ) ) {
				$dbw = $mainLB->getConnectionRef( DB_MASTER );
				$factory->beginMasterChanges( __METHOD__ );
				$result = $action( $dbw );
				$factory->commitMasterChanges( __METHOD__ );
				return $result;
			} else {
				// in MediaWiki 1.37 and later, some functions were renamed and others deprecated
				$dbw = $mainLB->getConnection( DB_PRIMARY );
				$factory->beginPrimaryChanges( __METHOD__ );
				$result = $action( $dbw );
				$factory->commitPrimaryChanges( __METHOD__ );
				return $result;
			}
{'fraction_non_alphanumeric': 0.13891190278928472, 'fraction_numerical': 0.0027616680475006906, 'mean_word_length': 4.677115987460815, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 18, 'https://': 2, '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': '3276385', 'n_tokens_mistral': 1208, 'n_tokens_neox': 1091, 'n_words': 269}