PHP code example of decodelabs / dictum

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

    

decodelabs / dictum example snippets


use DecodeLabs\Dictum;

echo Dictum::name('geoff-randomName');
// Geoff Random Name

echo Dictum::firstName('geoff-randomName');
// Geoff

echo Dictum::initials('geoff-randomName');
// GRN

echo Dictum::initialsAndSurname('geoff-randomName');
// GR Name

echo Dictum::initialMiddleNames('geoff-randomName');
// Geoff R Name


echo Dictum::consonants('here\'s a Random-string of text');
// hr's  Rndm-strng f txt

echo Dictum::label('here\'s a Random-string of text');
// Here's a random string of text

echo Dictum::id('here\'s a Random-string of text');
// HeresARandomStringOfText

echo Dictum::camel('here\'s a Random-string of text');
// heresARandomStringOfText

echo Dictum::constant('here\'s a Random-string of text');
// HERE_S_A_RANDOM_STRING_OF_TEXT


echo Dictum::slug('here\'s a Random-string of text / other stuff');
// heres-a-random-string-of-text-other-stuff

echo Dictum::pathSlug('here\'s a Random-string of text / other stuff');
// heres-a-random-string-of-text/other-stuff

echo Dictum::actionSlug('here\'s a Random-string of text / other stuff');
// here's-a-random-string-of-text-/-other-stuff

echo Dictum::fileName('here\'s a Random-string of text / other stuff');
// here's-a-Random-string-of-text-_-other-stuff

echo Dictum::shorten('here\'s a Random-string of text / other stuff', 10);
// here's a…


echo Dictum::numericToAlpha(23345452);
// aybfra

echo Dictum::alphaToNumeric('aybfra')
// 23345452

echo Dictum::toBoolean('yes') ? 'true' : 'false';
// true

echo (new Text($id))
    ->toUtf8()
    ->toAscii()
    ->regexReplace('([^ ])([A-Z])', '\\1 \\2')
    ->replace(['-', '.', '+'], ' ')
    ->regexReplace('[^a-zA-Z0-9_ ]', '')
    ->toTitleCase()
    ->replace(' ', '')
    ->__toString();

use DecodeLabs\Dictum;

// Custom format
Dictum::$time->format('now', 'd/m/Y', 'Europe/London');

// Locale format
// When timezone is true it is fetched from Cosmos::$timezone
Dictum::$time->locale('now', 'long', 'long', true);

// Locale shortcuts
Dictum::$time->dateTime('tomorrow'); // medium
Dictum::$time->longTime('yesterday');
Dictum::$time->shortDate('yesterday');
// ...etc


// Intervals
Dictum::$time->since('yesterday'); // 1 day ago
Dictum::$time->until('tomorrow'); // 1 day from now
Dictum::$time->sinceAbs('yesterday'); // 1 day
Dictum::$time->untilAbs('yesterday'); // -1 day
Dictum::$time->between('yesterday', 'tomorrow'); // 1 day



// Numbers
Dictum::$number->format(16.5, 'px'); // 16.5 px
Dictum::$number->format(16.5, 'px', 'de'); // 16,5 px
Dictum::$number->decimal(16.534643, 2); // 16.53
Dictum::$number->currency(16.534643, 'GBP'); // £16.53
Dictum::$number->percent(16.534643, 50, 2); // 33.07%
Dictum::$number->scientific(16.534643); // 1.6534643E1
Dictum::$number->spellout(16.534643); // sixteen point five three four six four three
Dictum::$number->ordinal(16.534643); // 17th
Dictum::$number->diff(16.534643); // ⬆ 16.535
Dictum::$number->fileSize(16534643); // 15.77 MiB
Dictum::$number->fileSizeDec(16534643); // 16.53 MB