HasLimit   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 0
dl 0
loc 19
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A limit() 0 8 2
1
<?php
2
3
namespace LaraComponents\Seo\Traits;
4
5
trait HasLimit
6
{
7
    /**
8
     * Limit the number of characters in a string.
9
     *
10
     * @param  string  $value
11
     * @param  int     $limit
12
     * @param  string  $end
13
     * @return string
14
     */
15
    protected function limit($value, $limit = 100, $end = '...')
16
    {
17
        if (mb_strwidth($value, 'UTF-8') <= $limit) {
18
            return $value;
19
        }
20
21
        return rtrim(mb_strimwidth($value, 0, $limit, '', 'UTF-8')).$end;
22
    }
23
}
24