| Total Complexity | 4 |
| Total Lines | 44 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 17 | final class RandomOrg implements GeneratorInterface |
||
| 18 | { |
||
| 19 | /** |
||
| 20 | * The Random.Org API. |
||
| 21 | */ |
||
| 22 | protected RandomOrgAPIInterface $randomOrgAPI; |
||
| 23 | |||
| 24 | public function __construct(RandomOrgAPIInterface $randomOrgAPI) |
||
| 27 | } |
||
| 28 | |||
| 29 | /** |
||
| 30 | * {@inheritdoc} |
||
| 31 | */ |
||
| 32 | public function generate($size): string |
||
| 33 | { |
||
| 34 | $provider = (new Provider())->withResource('generateStrings') |
||
| 35 | ->withParameters([ |
||
| 36 | 'n' => 1, |
||
| 37 | 'length' => $size, |
||
| 38 | 'characters' => implode( |
||
| 39 | '', |
||
| 40 | array_merge( |
||
| 41 | range('A', 'Z'), |
||
| 42 | range('a', 'z'), |
||
| 43 | range(0, 9) |
||
| 44 | ) |
||
| 45 | ), |
||
| 46 | ]); |
||
| 47 | |||
| 48 | $result = $this->randomOrgAPI->getData($provider); |
||
| 49 | |||
| 50 | return $result[0]; |
||
| 51 | } |
||
| 52 | |||
| 53 | public static function getPriority(): int |
||
| 56 | } |
||
| 57 | |||
| 58 | public static function isSupported(): bool |
||
| 61 | } |
||
| 62 | } |
||
| 63 |