Source of file TestRandomGenerator.php
Size: 1,313 Bytes - Last Modified: 2021-12-23T10:34:19+00:00
/var/www/docs.ssmods.com/process/src/tests/Service/TestRandomGenerator.php
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 | <?php namespace SilverStripe\Omnipay\Tests\Service; use SilverStripe\Dev\TestOnly; use SilverStripe\Security\RandomGenerator; /** * Class TestRandomGenerator * @package SilverStripe\Omnipay\Tests\Service */ class TestRandomGenerator extends RandomGenerator implements TestOnly { /** * @var array */ protected $entropy = []; /** * @var array */ protected $randomToken = []; /** * @param string ...$values */ public function addEntropy(...$values) { $this->entropy = array_merge($this->entropy, $values); } /** * @param string ...$tokens */ public function addRandomTokens(...$tokens) { $this->randomToken = array_merge($this->randomToken, $tokens); } /** * @return string * @throws \Exception */ public function generateEntropy() { if (!empty($this->entropy)) { return array_shift($this->entropy); } return parent::generateEntropy(); } /** * @param string $algorithm * @return string */ public function randomToken($algorithm = 'whirlpool') { if (!empty($this->randomToken)) { return array_shift($this->randomToken); } return parent::randomToken($algorithm); } } |