DefinitionFactory   A
last analyzed

Coupling/Cohesion

Components 0
Dependencies 2

Complexity

Total Complexity 4

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
lcom 0
cbo 2
dl 0
loc 22
ccs 6
cts 6
cp 1
rs 10
c 1
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A getDefinition() 0 14 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