SimpleEntityFactory   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 0
loc 18
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A get() 0 8 3
1
<?php
2
3
namespace Cube\DoctrineEntityFactory;
4
5
use Cube\DoctrineEntityFactory\Exception\InvalidArgumentException;
6
7
/**
8
 * Creates an entity directly - without passing any constructor arguments.
9
 *
10
 * @author Gabriel Somoza <[email protected]>
11
 */
12
final class SimpleEntityFactory implements EntityFactoryInterface
13
{
14
    /**
15
     * Gets an instance of the specified entity
16
     *
17
     * @param string $entityClassName
18
     *
19
     * @return object
20
     */
21 5
    public function get($entityClassName)
22
    {
23 5
        if (!is_string($entityClassName) || !class_exists($entityClassName)) {
24 4
            throw new InvalidArgumentException('Expected $entityClassName to be a valid class name.');
25
        }
26
27 1
        return new $entityClassName();
28
    }
29
}
30