PHP code example of drupol / yaroc

1. Go to this page and download the library: Download drupol/yaroc library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

drupol / yaroc example snippets




rupol\Yaroc\Plugin\Provider;
use drupol\Yaroc\RandomOrgAPI;

$generateIntegers = (new Provider())->withResource('generateIntegers')
    ->withParameters(['n' => 10, 'min' => 0, 'max' => 100]);

$result = (new RandomOrgAPI())
    ->withApiKey('00000000-0000-0000-0000-000000000000')
    ->getData($generateIntegers);

print_r($result);

$provider = (new Provider())->withResource('generateStrings')
    ->withParameters([
        'n' => 10,
        'length' => 15,
        'characters' => implode(array_merge(range('A', 'Z'), range('a', 'z'), range(0, 9))),
    ]);

$result = (new RandomOrgAPI(null, ['apiKey' => '00000000-0000-0000-0000-000000000000']))->getData($provider);

print_r($result);



rupol\Yaroc\RandomOrgAPI;
use drupol\Yaroc\Plugin\RandomLib\Source\RandomOrg;

$randomOrgApi = new RandomOrgAPI();

$randomLib = new RandomLib\Factory();
$generator = $randomLib->getGenerator(new SecurityLib\Strength(SecurityLib\Strength::HIGH))
  ->addSource(new RandomOrg($randomOrgApi));
$randomString = $generator->generateString(10);

echo $randomString;




rupol\Yaroc\RandomOrgAPI;
use drupol\Yaroc\Plugin\RychRandom\Generator\RandomOrg;

$randomOrgApi = new RandomOrgAPI();

$rychRandom = new Rych\Random\Random(new RandomOrg($randomOrgApi));
$randomString = $rychRandom->getRandomString(8);

echo $randomString;