SetterMethodName::fromSnakeCasePropertyName()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 8
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 10
ccs 9
cts 9
cp 1
crap 1
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Atlance\HttpDoctrineOrmFilter\Utils;
6
7
final class SetterMethodName
8
{
9 78
    private function __construct(private readonly string $name)
10
    {
11 78
    }
12
13 78
    public function getName(): string
14
    {
15 78
        return $this->name;
16
    }
17
18 78
    public static function fromSnakeCasePropertyName(string $propertyName): self
19
    {
20 78
        return new self(
21 78
            'set' . str_replace(
22 78
                ' ',
23 78
                '',
24 78
                mb_convert_case(
25 78
                    str_replace('_', ' ', $propertyName),
26 78
                    \MB_CASE_TITLE,
27 78
                    'UTF-8'
28 78
                )
29 78
            )
30 78
        );
31
    }
32
}
33