PHP code example of macmotp / codegen

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

    

macmotp / codegen example snippets

 php
use Macmotp\Codegen;

$generator = new Codegen();

echo $generator->generate('Bob McLovin');

// (string) 'BOMCLO'

echo $generator->generate('Company Name');

// (string) 'COMPNA'
 php
use Macmotp\Codegen;

$generator = new Codegen();

for ($i = 0; $i < 4; $i++) {
   echo $generator->generate('Bob McLovin');
}
// (string) 'BOMCLO'
// (string) 'BOMCLV'
// (string) 'BOMCLI'
// (string) 'BOMCLN'

// Or you can simply retrieve the codes directly within a collection:
echo $generator->collection('Bob McLovin', 4);

// (array) [
//    "BOMCLO",
//    "BOMCLV",
//    "BOMCLI",
//    "BOMCLN",
// ];
 php
use Macmotp\Codegen;

$generator = new Codegen();

echo $generator->setCodeLength(10)
        ->prepend('PR')
        ->append('AP')
        ->generate('Company Name');
// (string) 'PRCOMPNAAP'