Passed
Push — main ( 0ace76...960e41 )
by Daniel
04:09
created

StringHelper   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A filterForSearch() 0 5 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Uxmp\Core\Lib;
6
7
/**
8
 * Collection of string related methods
9
 */
10
final class StringHelper implements StringHelperInterface
11
{
12
    /**
13
     * Normalizes a string for search purposes
14
     *
15
     * In order to allow searches on utf8 content, transform
16
     * all strings to ascii and replace special characters like
17
     * å,ü,... by their ascii pendants a,u,...
18
     */
19 3
    public function filterForSearch(string $value): string
20
    {
21 3
        return trim(
22 3
            strtolower(
23 3
                (string) iconv('UTF-8', 'ASCII//TRANSLIT//IGNORE', $value)
24 3
            )
25 3
        );
26
    }
27
}
28