TypeResolver::resolveByType()   A
last analyzed

Complexity

Conditions 3
Paths 2

Size

Total Lines 9
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 9
rs 10
c 0
b 0
f 0
cc 3
nc 2
nop 1
1
<?php
2
3
namespace evelikto\di\resolver;
4
5
/** Resolves parameter using its type hint */
6
trait TypeResolver
7
{
8
    /**
9
     * Tries to resolve parameter by its type hint.
10
     *
11
     * @param   \ReflectionParameter  $param  Parameter to be resolved.
12
     * @return  mixed|null                    Resolved value or null.
13
     */
14
    protected function resolveByType(\ReflectionParameter $param) {
15
        if ($param->hasType() === false || $param->getType()->isBuiltin())
16
            return null;
17
18
        $name = $param->getClass()->getName();
19
        return $this->fromClass($name)
0 ignored issues
show
Bug introduced by
It seems like fromClass() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

19
        return $this->/** @scrutinizer ignore-call */ fromClass($name)
Loading history...
20
            ?? $this->fromInterfaceMethod($name)
0 ignored issues
show
Bug introduced by
It seems like fromInterfaceMethod() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

20
            ?? $this->/** @scrutinizer ignore-call */ fromInterfaceMethod($name)
Loading history...
21
            ?? $this->fromInterfaceAlias($name)
0 ignored issues
show
Bug introduced by
It seems like fromInterfaceAlias() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

21
            ?? $this->/** @scrutinizer ignore-call */ fromInterfaceAlias($name)
Loading history...
22
            ?? null;
23
    }
24
}