Strings::normalize()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 3
c 0
b 0
f 0
dl 0
loc 8
ccs 4
cts 4
cp 1
rs 10
cc 2
nc 2
nop 2
crap 2
1
<?php
2
3
namespace Riesenia\Pohoda\Common\OptionsResolver\Normalizers;
4
5
class Strings extends AbstractNormalizer
6
{
7 98
    public function normalize(mixed $options, mixed $value): string
8
    {
9
        // remove new lines
10 98
        $value = \str_replace(["\r\n", "\r", "\n"], ' ', \strval($value));
11
12
        // param is used for string length
13 98
        $length = empty($this->length) ? null : \intval($this->length);
14 98
        return \mb_substr(\strval($value), 0, $length, 'utf-8');
15
    }
16
}
17