String

Extended version of Laravel's Str componentopen in new window.

randomizer()

The randomizer() method returns a StringRandomizer component - an adapter for PHP Random\Randomizeropen in new window.

use Aedart\Utils\Str;

$randomizer = Str::randomizer();

You can optionally specify what Engineopen in new window you wish to use:

use Aedart\Utils\Str;
use Random\Engine\Mt19937;

$randomizer = Str::randomizer(new Mt19937());

bytes()

Returns random bytes.

Str::randomizer()->bytes(10); // \pǓY��n

See Random\Randomizer::getBytes()open in new window for details.

shuffle()

Shuffles given bytes.

$chars = implode('', range('a', 'z'));
Str::randomizer()->shuffle($chars); // lgtkrcvenbodmfzauxhqyiwjsp

See Random\Randomizer::shuffleBytes()open in new window for details.

slugToWords()

Method converts a slug back to words.

use Aedart\Utils\Str;

echo (string) Str::slugToWords('my-slug'); // My Slug