String
Extended version of Laravel's Str
component.
randomizer()
The randomizer()
method returns a StringRandomizer
component - an adapter for PHP Random\Randomizer
.
use Aedart\Utils\Str;
$randomizer = Str::randomizer();
You can optionally specify what Engine
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()
for details.
shuffle()
Shuffles given bytes.
$chars = implode('', range('a', 'z'));
Str::randomizer()->shuffle($chars); // lgtkrcvenbodmfzauxhqyiwjsp
See Random\Randomizer::shuffleBytes()
for details.
slugToWords()
Method converts a slug back to words.
use Aedart\Utils\Str;
echo (string) Str::slugToWords('my-slug'); // My Slug