public static function ellipsize(string $string, int $maxLength, string $suffix = '...') : string
    {
        if ($maxLength < 0) {
            throw new \InvalidArgumentException('$maxLength is negative');
        }

        if (strlen($string) <= $maxLength) {
            return $string;
        }

        $trimmedLength = $maxLength - strlen($suffix);
        $string = substr($string, 0, max(0, $trimmedLength));

        if ($string === '') {
            return substr($suffix, 0, $maxLength);
        }

        return $string . $suffix;
    }