App\Libraries\Str::head PHP Метод

head() публичный статический Метод

The start (head) of a string will be returned with an ellipsis after it where the text is cut.
public static head ( $value, integer $limit = 100, string $end = '...' ) : string
$value
$limit integer
$end string
Результат string
    public static function head($value, $limit = 100, $end = '...')
    {
        $value_len = strlen($value);
        $end_len = strlen($end);
        $head_end = $limit - $end_len;
        if ($limit >= $value_len) {
            return $value;
        } else {
            return substr($value, 0, $head_end) . $end;
        }
    }