HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: /var/www/html/triad-infosec/wp-content/plugins/the-events-calendar/src/Tribe/Utils/Id_Generator.php
<?php


class Tribe__Events__Utils__Id_Generator {

	protected static $count = [];

	public static function generate_id( $string, $group = 'default' ) {

		if ( ! ( is_string( $string ) || ( is_int( $string ) ) ) ) {
			throw new InvalidArgumentException( 'First argument must be a string or an int' );
		}

		if ( ! ( is_string( $group ) || is_int( $group ) ) ) {
			throw new InvalidArgumentException( 'Group argument must be a string' );
		}

		if ( ! isset( self::$count[ $group ] ) ) {
			self::$count[ $group ] = 0;
		}

		$out = $string . '-' . self::$count[ $group ];
		self::$count[ $group ] ++;

		return $out;
	}

	public static function reset( $group = null ) {
		if ( empty( $group ) ) {
			self::$count = [];
		} else {
			self::$count[ $group ] = 0;
		}
	}
}