Conditions | 3 |
Paths | 2 |
Total Lines | 13 |
Code Lines | 6 |
Lines | 0 |
Ratio | 0 % |
Tests | 7 |
CRAP Score | 3 |
Changes | 0 |
1 | <?php |
||
43 | 340 | private static function getClass(string $name): AttributeInterface |
|
44 | { |
||
45 | 340 | $normalizeName = ucfirst(strtolower($name)); |
|
46 | |||
47 | /** @var class-string<AttributeInterface> $classString */ |
||
48 | 340 | $classString = sprintf('\Enjoys\Forms\Attributes\%sAttribute', $normalizeName); |
|
49 | 340 | $classFile = sprintf(__DIR__ . '/Attributes/%sAttribute.php', $normalizeName); |
|
50 | |||
51 | 340 | if (is_file($classFile) && class_exists($classString)) { |
|
52 | 331 | return new $classString(); |
|
53 | } |
||
54 | |||
55 | 307 | return (new Base())->withName($name); |
|
56 | } |
||
58 |