Test Failed
Push — main ( 5edb73...d2cb63 )
by Fractal
02:48
created

SerializerHelper::getSerializedNameAttribute()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 1
nop 1
dl 0
loc 8
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace FRZB\Component\RequestMapper\Helper;
6
7
use Symfony\Component\Serializer\Annotation\SerializedName;
8
9
/**
10
 * @internal
11
 */
12
final class SerializerHelper
13
{
14
    public static function getSerializedNameAttribute(\ReflectionProperty $rProperty): SerializedName
15
    {
16
        $attributes = array_map(
17
            static fn (\ReflectionAttribute $a) => $a->newInstance(),
18
            $rProperty->getAttributes(SerializedName::class),
19
        );
20
21
        return current($attributes) ?: new SerializedName($rProperty->getName());
22
    }
23
}
24