SimpleEntityFactory::get()   A
last analyzed

Complexity

Conditions 3
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 3

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 4
cts 4
cp 1
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 4
nc 2
nop 1
crap 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