StringUtil   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 14
ccs 5
cts 5
cp 1
rs 10
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A getSummary() 0 7 3
1
<?php
2
3
namespace App\Infrastructure\Utils;
4
5
class StringUtil
6
{
7
    /**
8
     * @param string|null $body
9
     * @param int $maxLength
10
     * @return string
11
     */
12 23
    public static function getSummary(?string $body, int $maxLength = 250): string
13
    {
14 23
        if ($body === null) {
15 2
            return "";
16
        }
17 21
        $short = strlen($body) - 1 < $maxLength ? $body : trim(substr($body, 0, $maxLength)). "...";
18 21
        return strip_tags($short) ;;
19
    }
20
}