<?php
namespace App\Libraries;
/**
 * Created by PhpStorm.
 * User: UNTREF
 * Date: 3/11/2017
 * Time: 3:51 PM
 */

use Illuminate\Support\Facades\URL;

class Utils
{

    /**
     *
     * corta el texto a cantidad de caracteres en template
     */
    public static function cutText($string, $cant = 250)
    {

        $string = strip_tags($string);
        if (strlen($string) > $cant) {
            if (substr($string, $cant - 1, 1) != ' ') {
                $string = substr($string, '0', $cant);
                $array = explode(' ', $string);
                array_pop($array);
                $new_string = implode(' ', $array);

                return $new_string . '...';
            } else {
                return substr($string, '0', $cant - 1) . '...';
            }
        } else {
            return $string;
        }
    }

}