CamelCaseToSnakeCaseConverter::convert()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 13

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 13
ccs 8
cts 8
cp 1
rs 9.8333
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Paysera\Bundle\ApiBundle\Service\Validation;
5
6
class CamelCaseToSnakeCaseConverter implements PropertyPathConverterInterface
7
{
8 10
    public function convert($path)
9
    {
10 10
        return ltrim(
11 10
            mb_strtolower(
12 10
                preg_replace(
13 10
                    '/[A-Z]/u',
14 10
                    '_$0',
15 10
                    $path
16
                )
17
            ),
18 10
            '_'
19
        );
20
    }
21
}
22