PHP code example of wllcdev / arda-tokens

1. Go to this page and download the library: Download wllcdev/arda-tokens 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/ */

    

wllcdev / arda-tokens example snippets


use Wllcdev\ArdaTokens\Arda;

// Generate a token
$token = Arda::token();  // "precious-frodo"

use Wllcdev\ArdaTokens\Arda;

// Default: no suffix
Arda::generate();     // "elvish-gandalf"
Arda::token();        // "hobbitish-shire" (alias)

// With suffix (1-4 characters)
Arda::generate(1);    // "golden-ring-f"
Arda::generate(2);    // "shadowy-mordor-4e"
Arda::generate(3);    // "mithril-aragorn-a3f"
Arda::generate(4);    // "starlit-galadriel-8f2a" (max)

// Invalid suffix length throws exception
Arda::generate(5);    // InvalidArgumentException
Arda::generate(-1);   // InvalidArgumentException

use Wllcdev\ArdaTokens\Arda;

// Base capacity (no suffix)
Arda::capacity();              // 12,600
Arda::capacityWithSuffix(0);   // 12,600 (same as capacity())

// With hex suffix
Arda::capacityWithSuffix(1);   // 201,600
Arda::capacityWithSuffix(2);   // 3,225,600
Arda::capacityWithSuffix(3);   // 51,609,600
Arda::capacityWithSuffix(4);   // 825,753,600