| 1 | <?php |
||
| 16 | class RandomBytesGenerator implements Generator |
||
| 17 | { |
||
| 18 | /** |
||
| 19 | * @var int |
||
| 20 | */ |
||
| 21 | private $bytes_length; |
||
| 22 | |||
| 23 | /** |
||
| 24 | * @param int $bytes_length |
||
| 25 | */ |
||
| 26 | 4 | public function __construct($bytes_length = 8) |
|
| 27 | { |
||
| 28 | 4 | if (!is_int($bytes_length)) { |
|
| 29 | 1 | throw new ArgumentTypeException(sprintf('Length of bytes should be integer, got "%s" instead.', gettype($bytes_length))); |
|
| 30 | } |
||
| 31 | |||
| 32 | 3 | if ($bytes_length <= 0) { |
|
| 33 | 1 | throw new ZeroArgumentException(sprintf('Length of bytes should be grate then "0", got "%d" instead.', $bytes_length)); |
|
| 34 | } |
||
| 35 | |||
| 36 | 2 | $this->bytes_length = $bytes_length; |
|
| 37 | 2 | } |
|
| 38 | |||
| 39 | /** |
||
| 40 | * @return string |
||
| 41 | */ |
||
| 42 | 2 | public function generate() |
|
| 50 | } |
||
| 51 |