Passed
Push — master ( 29344f...675168 )
by Paweł
03:21 queued 12s
created

EntityMock   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Test Coverage

Coverage 88.89%

Importance

Changes 2
Bugs 0 Features 1
Metric Value
eloc 10
c 2
b 0
f 1
dl 0
loc 19
rs 10
ccs 8
cts 9
cp 0.8889
wmc 4

1 Method

Rating   Name   Duplication   Size   Complexity  
A create() 0 17 4
1
<?php
2
/**
3
 * Copyright (c) 2020.
4
 * @author Paweł Antosiak <[email protected]>
5
 */
6
7
declare(strict_types=1);
8
9
namespace Gorynych\Testing;
10
11
use Faker\Factory;
12
13
final class EntityMock
14
{
15 1
    public static function create(string $entityClassName): self
16
    {
17 1
        $self = new self();
18 1
        $valueResolver = new FakerValueResolver(Factory::create());
19
20 1
        foreach ((new \ReflectionClass($entityClassName))->getProperties() as $property) {
21
            if (
22 1
                'id' === $property->getName() ||
23 1
                null === $value = $valueResolver->resolvePropertyValue($property)
24
            ) {
25
                continue;
26
            }
27
28 1
            $self->{$property->getName()} = $value;
29
        }
30
31 1
        return $self;
32
    }
33
}
34