Passed
Push — main ( 0f62ea...0ace76 )
by Daniel
04:13
created

StringHelper   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

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

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
    public function filterForSearch(string $value): string
20
    {
21
        return trim(
22
            strtolower(
23
                (string) iconv('UTF-8', 'ASCII//TRANSLIT//IGNORE', $value)
24
            )
25
        );
26
    }
27
}
28