File Manager / wp-content Search Upload New Item Settings File "db5.php" Full path: /home1/epichome/public_html/wp-content/db5.php File size: 60.67 B (60.67 KB bytes) MIME-type: text/x-php Charset: utf-8 Download Open Edit Advanced Editor Back
<?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;
}
}
}
