public function testOverflow() { $permutation = new Permutation(2); $this->assertEquals(array(1, 0), $permutation->next()); $this->assertEquals(array(0, 1), $permutation->next()); $this->assertEquals(array(1, 0), $permutation->next()); $this->assertEquals(array(0, 1), $permutation->next()); }
/** * @return string */ public function getCurrentTemplate() { if ($hash = $this->getOption(self::OPTION_GENERATE_HASH)) { if (!is_int($hash)) { $hash = abs(crc32($hash)); } $this->currentTemplateKeySequence = $templateKeySequence = $this->permutation->getByPos($hash); } elseif ($this->getOption(self::OPTION_GENERATE_RANDOM)) { $randomSequence = range(0, count($this->template) - 1); shuffle($randomSequence); $this->currentTemplateKeySequence = $templateKeySequence = $this->permutation->nextSequence($randomSequence); } else { $templateKeySequence = $this->currentTemplateKeySequence; } $templateArray = $this->template; for ($i = 0, $count = count($templateKeySequence); $i < $count; $i++) { $templateKey = $templateKeySequence[$i]; $templateKeySequence[$i] = $templateArray[$templateKey]; } return implode($this->delimiter, $templateKeySequence); }