1 | <?php |
||
29 | class Generator extends \RandomLib\Generator { |
||
30 | protected $callbacks = array(); |
||
31 | |||
32 | public static function init() {} |
||
33 | |||
34 | public function __construct(array $callbacks = array()) { |
||
35 | $this->callbacks = $callbacks; |
||
36 | } |
||
37 | |||
38 | public function __call($name, array $args = array()) { |
||
39 | if (isset($this->callbacks[$name])) { |
||
40 | return call_user_func_array($this->callbacks[$name], $args); |
||
41 | } |
||
42 | return null; |
||
43 | } |
||
44 | |||
45 | public function addSource(\PasswordLib\Random\Source $source) { |
||
46 | return $this->__call('addSource', array($source)); |
||
47 | } |
||
48 | |||
49 | public function generate($size) { |
||
50 | return $this->__call('generate', array($size)); |
||
51 | } |
||
52 | |||
53 | public function generateInt($min = 0, $max = \PHP_INT_MAX) { |
||
54 | return $this->__call('generateInt', array($min, $max)); |
||
55 | } |
||
56 | |||
57 | public function generateString($length, $chars = '') { |
||
58 | return $this->__call('generateString', array($length, $chars)); |
||
59 | } |
||
60 | |||
61 | } |
||
62 |