Completed
Push — master ( c628d7...8aa25c )
by Miloš
01:17
created

ClassResolver::__invoke()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2.032

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 2
dl 0
loc 10
ccs 4
cts 5
cp 0.8
crap 2.032
rs 9.9332
c 0
b 0
f 0
1
<?php
2
3
namespace Laganica\Di\Resolver;
4
5
use Laganica\Di\Exception\NotFoundException;
6
7
/**
8
 * Class AutowireResolver
9
 *
10
 * @package Laganica\Di\Resolver
11
 */
12
class ClassResolver extends ReflectionResolver
13
{
14
    /**
15
     * @inheritDoc
16
     */
17 5
    public function resolve($class)
18
    {
19 5
        if (class_exists($class)) {
20 5
            $params = $this->getConstructorParams($class);
0 ignored issues
show
Bug introduced by
It seems like $class defined by parameter $class on line 17 can also be of type object<Closure> or object<Laganica\Di\Defin...on\DefinitionInterface>; however, Laganica\Di\Resolver\Ref...:getConstructorParams() does only seem to accept string, maybe add an additional type check?

This check looks at variables that have been passed in as parameters and are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
21
22 5
            return new $class(...$params);
23
        }
24
25
        throw NotFoundException::create($class);
0 ignored issues
show
Bug introduced by
It seems like $class defined by parameter $class on line 17 can also be of type object<Closure> or object<Laganica\Di\Defin...on\DefinitionInterface>; however, Laganica\Di\Exception\NotFoundException::create() does only seem to accept string, maybe add an additional type check?

This check looks at variables that have been passed in as parameters and are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
26
    }
27
}
28