TestRNGProvider.php 732 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. namespace Tests\Providers\Rng;
  3. use RobThree\Auth\Providers\Rng\IRNGProvider;
  4. class TestRNGProvider implements IRNGProvider
  5. {
  6. /** @var bool */
  7. private $isSecure;
  8. /**
  9. * @param bool $isSecure whether this provider is cryptographically secure
  10. */
  11. function __construct($isSecure = false)
  12. {
  13. $this->isSecure = $isSecure;
  14. }
  15. /**
  16. * {@inheritdoc}
  17. */
  18. public function getRandomBytes($bytecount)
  19. {
  20. $result = '';
  21. for ($i = 0; $i < $bytecount; $i++) {
  22. $result .= chr($i);
  23. }
  24. return $result;
  25. }
  26. /**
  27. * {@inheritdoc}
  28. */
  29. public function isCryptographicallySecure()
  30. {
  31. return $this->isSecure;
  32. }
  33. }