Resolver   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 80%

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 1
dl 0
loc 44
ccs 4
cts 5
cp 0.8
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A __invoke() 0 10 4
1
<?php
2
/**
3
 * Fusible\EventProvider
4
 *
5
 * PHP version 5
6
 *
7
 * Copyright (C) 2016 Jake Johns
8
 *
9
 * This software may be modified and distributed under the terms
10
 * of the MIT license.  See the LICENSE file for details.
11
 *
12
 * @category  Resolver
13
 * @package   Fusible\EventProvider
14
 * @author    Jake Johns <[email protected]>
15
 * @copyright 2016 Jake Johns
16
 * @license   http://jnj.mit-license.org/2016 MIT License
17
 * @link      https://github.com/fusible/fusible.event-provider
18
 */
19
20
namespace Fusible\EventProvider;
21
22
use Aura\Di\Injection\InjectionFactory;
23
24
/**
25
 * Resolver
26
 *
27
 * @category Resolver
28
 * @package  Fusible\EventProvider
29
 * @author   Jake Johns <[email protected]>
30
 * @license  http://jnj.mit-license.org/ MIT License
31
 * @link     https://github.com/fusible/fusible.event-provider
32
 */
33
class Resolver
34
{
35
36
    /**
37
     * Injection Factory
38
     *
39
     * @var InjectionFactory
40
     *
41
     * @access protected
42
     */
43
    protected $injectionFactory;
44
45
    /**
46
     * __construct
47
     *
48
     * @param InjectionFactory $injectionFactory DI Factory
49
     *
50
     * @access public
51
     */
52 3
    public function __construct(InjectionFactory $injectionFactory)
53
    {
54 3
        $this->injectionFactory = $injectionFactory;
55
    }
56
57
    /**
58
     * __invoke
59
     *
60
     * @param mixed $spec spec to resolve
61
     *
62
     * @return mixed
63
     *
64
     * @access public
65
     */
66 1
    public function __invoke($spec)
67
    {
68
        if (is_string($spec)) {
69
            return $this->injectionFactory->newInstance($spec);
70
        }
71
        if (is_array($spec) && is_string($spec[0])) {
72
            $spec[0] = $this->injectionFactory->newInstance($spec[0]);
73
        }
74 1
        return $spec;
75
    }
76
}
77
78