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

ClassResolver   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 80%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A resolve() 0 10 2
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