ReflectionConstructorFactory   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 0
dl 0
loc 27
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A createEntity() 0 6 1
1
<?php
2
3
namespace ScayTrase\Api\Cruds;
4
5
final class ReflectionConstructorFactory implements EntityFactoryInterface
6
{
7
    /** @var  string */
8
    private $className;
9
    /** @var  array */
10
    private $args = [];
11
12
    /**
13
     * ReflectionConstructorFactory constructor.
14
     *
15
     * @param string $className
16
     * @param array  $args
17
     */
18 10
    public function __construct($className, array $args = [])
19
    {
20 10
        $this->className = $className;
21 10
        $this->args      = $args;
22 10
    }
23
24
    /** {@inheritdoc} */
25 10
    public function createEntity($data)
26
    {
27 10
        $reflection = new \ReflectionClass($this->className);
28
29 10
        return $reflection->newInstanceArgs($this->args);
30
    }
31
}
32