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\HttpDbalFilter\Utils;
6
7
final class SetterMethodName
8
{
9 75
    private function __construct(private readonly string $name)
10
    {
11 75
    }
12
13 75
    public function getName(): string
14
    {
15 75
        return $this->name;
16
    }
17
18 75
    public static function fromSnakeCasePropertyName(string $propertyName): self
19
    {
20 75
        return new self(
21 75
            'set' . str_replace(
22 75
                ' ',
23 75
                '',
24 75
                mb_convert_case(
25 75
                    str_replace('_', ' ', $propertyName),
26 75
                    \MB_CASE_TITLE,
27 75
                    'UTF-8'
28 75
                )
29 75
            )
30 75
        );
31
    }
32
}
33