DefinitionFactory::getDefinition()   A
last analyzed

Complexity

Conditions 4
Paths 3

Size

Total Lines 14
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 4

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 14
c 1
b 0
f 0
ccs 6
cts 6
cp 1
rs 9.2
cc 4
eloc 6
nc 3
nop 2
crap 4
1
<?php
2
3
namespace League\Container\Definition;
4
5
use League\Container\ImmutableContainerAwareTrait;
6
7
class DefinitionFactory implements DefinitionFactoryInterface
8
{
9
    use ImmutableContainerAwareTrait;
10
11
    /**
12
     * {@inheritdoc}
13
     */
14 48
    public function getDefinition($alias, $concrete)
15
    {
16 48
        if (is_callable($concrete)) {
17 42
            return (new CallableDefinition($alias, $concrete))->setContainer($this->getContainer());
18
        }
19
20 12
        if (is_string($concrete) && class_exists($concrete)) {
21 6
            return (new ClassDefinition($alias, $concrete))->setContainer($this->getContainer());
22
        }
23
24
        // if the item is not definable we just return the value to be stored
25
        // in the container as an arbitrary value/instance
26 9
        return $concrete;
27
    }
28
}
29