summaryrefslogtreecommitdiffstatshomepage
path: root/tests/phpunit/includes/factory/class-wp-unittest-generator-sequence.php
blob: 9391dd8bf7d9ce7b2cf7e38c5297ab285c6673cd (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php

class WP_UnitTest_Generator_Sequence {
	public static $incr = -1;
	public $next;
	public $template_string;

	public function __construct( $template_string = '%s', $start = null ) {
		if ( $start ) {
			$this->next = $start;
		} else {
			self::$incr++;
			$this->next = self::$incr;
		}
		$this->template_string = $template_string;
	}

	public function next() {
		$generated = sprintf( $this->template_string, $this->next );
		$this->next++;
		return $generated;
	}

	/**
	 * Get the incrementor.
	 *
	 * @since 4.6.0
	 *
	 * @return int
	 */
	public function get_incr() {
		return self::$incr;
	}

	/**
	 * Get the template string.
	 *
	 * @since 4.6.0
	 *
	 * @return string
	 */
	public function get_template_string() {
		return $this->template_string;
	}
}