class-wp-unittest-generator-sequence.php 768 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. class WP_UnitTest_Generator_Sequence {
  3. public static $incr = -1;
  4. public $next;
  5. public $template_string;
  6. public function __construct( $template_string = '%s', $start = null ) {
  7. if ( $start ) {
  8. $this->next = $start;
  9. } else {
  10. self::$incr++;
  11. $this->next = self::$incr;
  12. }
  13. $this->template_string = $template_string;
  14. }
  15. public function next() {
  16. $generated = sprintf( $this->template_string, $this->next );
  17. $this->next++;
  18. return $generated;
  19. }
  20. /**
  21. * Get the incrementor.
  22. *
  23. * @since 4.6.0
  24. *
  25. * @return int
  26. */
  27. public function get_incr() {
  28. return self::$incr;
  29. }
  30. /**
  31. * Get the template string.
  32. *
  33. * @since 4.6.0
  34. *
  35. * @return string
  36. */
  37. public function get_template_string() {
  38. return $this->template_string;
  39. }
  40. }