Completed
Pull Request — master (#1)
by Woody
27:07 queued 01:07
created

ResolverTrait::resolve()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2
Metric Value
dl 0
loc 8
ccs 4
cts 4
cp 1
rs 9.4286
cc 2
eloc 4
nc 2
nop 1
crap 2
1
<?php
2
3
namespace Equip\Resolver;
4
5
trait ResolverTrait
6
{
7
    /**
8
     * @var \Relay\ResolverInterface
9
     */
10
    private $resolver;
11
12
    /**
13
     * Resolve a class spec into an object, if it is not already instantiated.
14
     *
15
     * @param string|object $specOrObject
16
     *
17
     * @return object
18
     */
19 4
    private function resolve($specOrObject)
20
    {
21 4
        if (is_object($specOrObject)) {
22 1
            return $specOrObject;
23
        }
24
25 4
        return call_user_func($this->resolver, $specOrObject);
26
    }
27
}
28