blob: 7179521edb21ea559e1027a302789a7bcc2b4090 [file] [log] [blame]
Matthias Andreas Benkard7b2a3a12021-08-16 10:57:25 +02001<?php
2
3namespace Tests\Providers\Rng;
4
5use RobThree\Auth\Providers\Rng\IRNGProvider;
6
7class TestRNGProvider implements IRNGProvider
8{
9 /** @var bool */
10 private $isSecure;
11
12 /**
13 * @param bool $isSecure whether this provider is cryptographically secure
14 */
15 function __construct($isSecure = false)
16 {
17 $this->isSecure = $isSecure;
18 }
19
20 /**
21 * {@inheritdoc}
22 */
23 public function getRandomBytes($bytecount)
24 {
25 $result = '';
26
27 for ($i = 0; $i < $bytecount; $i++) {
28 $result .= chr($i);
29 }
30
31 return $result;
32 }
33
34 /**
35 * {@inheritdoc}
36 */
37 public function isCryptographicallySecure()
38 {
39 return $this->isSecure;
40 }
41}