PHP code example of ssitu / bernardo

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

    

ssitu / bernardo example snippets


use SSITU\Bernardo;

nardo();
# OR
$adtDictionnary = ['qwibqwib','jeffkoons'];
$Bernardo = new Bernardo($adtDictionnary); // will be added to the default one

# All-in-one methods:

$Bernardo->isValidSubDomain($entry, $returnSuggestion = false, $strict = true, $minLen = 4, $maxLen = 20);
$Bernardo->isValidUsername($entry, $returnSuggestion = false, $strict = true, $minLen = 4, $maxLen = 20);

# Cherry-pick methods:

// These 4 methods will handle diacritics substitution:
$Bernardo->formatSubdomain($entry, $minLen = 4, $maxLen = 20);
$Bernardo->formatUsername($entry, $minLen = 4, $maxLen = 20);
$Bernardo->format($entry, $pattern, $toLower = false, $minLen = 4, $maxLen = 20);
$Bernardo->replaceDiacr($entry);

// For these 3, diacritics MUST have been handled beforehand (or expect possibly wrong returns):
$Bernardo->isValid($noDiacrEntry, $strict = true);
$Bernardo->strictExtractForbidden($noDiacrEntry, $stopAtFirst = false);
$Bernardo->extractForbidden($noDiacrEntry);

// Adjustements:
$Bernardo->cleanEntry($entry, $matches);
$Bernardo->forceLength($entry, $minLen = 4, $maxLen = 20);