2016-01-19 04:55:19 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class WP_UnitTest_Generator_Sequence {
|
|
|
|
static $incr = -1;
|
|
|
|
public $next;
|
|
|
|
public $template_string;
|
|
|
|
|
2019-03-15 13:15:08 +01:00
|
|
|
public function __construct( $template_string = '%s', $start = null ) {
|
2016-01-19 04:55:19 +01:00
|
|
|
if ( $start ) {
|
|
|
|
$this->next = $start;
|
|
|
|
} else {
|
|
|
|
self::$incr++;
|
|
|
|
$this->next = self::$incr;
|
|
|
|
}
|
|
|
|
$this->template_string = $template_string;
|
|
|
|
}
|
|
|
|
|
2019-03-15 13:15:08 +01:00
|
|
|
public function next() {
|
2017-12-01 00:09:33 +01:00
|
|
|
$generated = sprintf( $this->template_string, $this->next );
|
2016-01-19 04:55:19 +01:00
|
|
|
$this->next++;
|
|
|
|
return $generated;
|
|
|
|
}
|
2016-04-22 16:35:52 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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;
|
|
|
|
}
|
2016-01-19 04:55:19 +01:00
|
|
|
}
|