PHP code example of philippelyp / llmuid

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

    

philippelyp / llmuid example snippets


use LLMUID\LLMUID;

$r = new LLMUID();

$id = $r->mint();                     // K7-M3-XR-9D-Q2

$r->resolve('K7-M3-XR-9D-Q2');        // K7-M3-XR-9D-Q2, pristine
$r->resolve('`k7 m3 xr 9d q2`');      // K7-M3-XR-9D-Q2, delimiters and case
$r->resolve('K7-M3-XB-9D-Q2');        // K7-M3-XR-9D-Q2, one substitution
$r->resolve('K7-M3-RX-9D-Q2');        // K7-M3-XR-9D-Q2, one transposition

$r->resolve('K7-M3-ZZ-ZZ-Q2');        // FALSE
$r->last_error();                     // 'Checksum failed and no issued
                                      //  identifier is within 2 edits'

$id = $r->mint('invoice');

$r->resolve($id, 'invoice');          // the identifier
$r->resolve($id, 'receipt');          // FALSE
$r->last_error();                     // 'Wrong context: ... was not issued
                                      //  under this context'

$issued = $r->registry();             // array of canonical renderings

$r = new LLMUID($issued);             // same registry, new process

mint(string $context = ''): string|false
resolve(string $llmuid, string $context = ''): string|false
registry(): array
last_error(): string|false
self_test(): bool

$r->self_test();                      // TRUE
$r->last_error();                     // the first failing case, if not

$r->resolve('see invoice K7-M3-XR-9D-Q2 today');   // FALSE, too long
sh
php -l src/LLMUID.php

php -r 'pass\n" : $r->last_error() . "\n";'