Alias   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 0
loc 36
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getAlias() 0 4 1
A __invoke() 0 4 1
1
<?php
2
3
namespace Interop\Container\Factories;
4
5
use Psr\Container\ContainerInterface;
6
7
/**
8
 * A factory that creates an alias to another container entry.
9
 */
10
final class Alias
11
{
12
    private $alias;
13
14
    /**
15
     * Creates an alias.
16
     *
17
     * @param string $alias The identifier of the container entry that is aliased
18
     */
19
    public function __construct($alias)
20
    {
21
        $this->alias = $alias;
22
    }
23
24
    /**
25
     * Returns the identifier of the container entry that is aliased.
26
     *
27
     * @return string
28
     */
29
    public function getAlias()
30
    {
31
        return $this->alias;
32
    }
33
34
    /**
35
     * Returns the alias.
36
     *
37
     * @param ContainerInterface $container
38
     *
39
     * @return mixed
40
     */
41
    public function __invoke(ContainerInterface $container)
42
    {
43
        return $container->get($this->alias);
44
    }
45
}
46