PHP code example of lemmon / id

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

    

lemmon / id example snippets


use Lemmon\Id\Id;

$id = Id::generate();                    // "kwe7wndx4t" — canonical, lowercase
echo strtoupper($id);                    // "KWE7WNDX4T" — display form
echo Id::chunk(strtoupper($id));         // "KWE7-WNDX-4T"

// Accepting a transcribed ID back:
$input = Id::normalize('KWE1-WNDX-4T');   // user misread 7 as 1 → repaired

if (!Id::isValid($input, 10) || !Id::verifyCheck($input)) {
    // Reject malformed, wrong-length, or mistyped input.
}

Id::chunk('kwe7wndx4t');           // "kwe7-wndx-4t"
Id::chunk('kwe7wndx4t', 2, ' ');   // "kw e7 wn dx 4t"

Id::normalize(Id::chunk($id)) === $id;  // true

Id::normalize('  TNX-44 HD.TXK ');  // "tnx44hdtxk"

$id = Id::normalize($typed);

if (!Id::isValid($id, 10) || !Id::verifyCheck($id)) {
    // Ask the person to check the transcription.
}

Id::verifyCheck('kwe7wndx4t');   // true
Id::verifyCheck('kwe7wndx4x');   // false

Id::generate();                                         // default blocklist
Id::generate(10, [...Id::DEFAULT_BLOCKLIST, 'merch']);  // add an app-specific term
Id::generate(10, []);                                   // disable filtering

Id::generate();                        // no limit (default)
Id::generate(10, Id::DEFAULT_BLOCKLIST, 2);   // "kwwe..." ok, "kwwwe..." retried
Id::generate(10, Id::DEFAULT_BLOCKLIST, 1);   // no two adjacent characters may match