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

ObjectHelper   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 19
rs 10
c 0
b 0
f 0
wmc 4

1 Method

Rating   Name   Duplication   Size   Complexity  
A isArrayHasAllPropertiesFromClass() 0 17 4
1
<?php
2
3
declare(strict_types=1);
4
5
namespace FRZB\Component\RequestMapper\Helper;
6
7
/**
8
 * @internal
9
 */
10
final class ObjectHelper
11
{
12
    public static function isArrayHasAllPropertiesFromClass(array $array, string $class): bool
13
    {
14
        try {
15
            $rClass = new \ReflectionClass($class);
16
        } catch (\ReflectionException) {
17
            return false;
18
        }
19
20
        foreach ($rClass->getProperties() as $property) {
21
            $propertyValue = $array[$property->getName()] ?? $array[StringHelper::toSnakeCase($property->getName())] ?? null;
22
23
            if (!$propertyValue) {
24
                return false;
25
            }
26
        }
27
28
        return true;
29
    }
30
}
31