for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace FondBot\Helpers;
class Str
{
/**
* Determine if a given string ends with a given substring.
*
* @param string $haystack
* @param string|array $needles
* @return bool
*/
public static function endsWith(string $haystack, $needles): bool
foreach ((array) $needles as $needle) {
if (substr($haystack, -strlen($needle)) === (string) $needle) {
return true;
}
return false;
* Generate a more truly "random" alpha-numeric string.
* @param int $length
* @return string
public static function random(int $length = 16): string
$string = '';
while (($len = strlen($string)) < $length) {
$size = $length - $len;
$bytes = random_bytes($size);
$string .= substr(str_replace(['/', '+', '='], '', base64_encode($bytes)), 0, $size);
return $string;
* Convert the given string to lower-case.
* @param string $value
public static function lower($value)
return mb_strtolower($value, 'UTF-8');