NameResolver   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 3
dl 0
loc 20
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A resolveStoredByName() 0 2 1
A resolveMethodByName() 0 2 1
1
<?php
2
3
namespace evelikto\di\resolver;
4
5
/** Resolves parameter using its name */
6
trait NameResolver
7
{
8
    /**
9
     * Tries to resolve parameter by its name from previously resolved dependencies.
10
     *
11
     * @param   \ReflectionParameter  $param  Parameter to be resolved.
12
     * @return  mixed|null                    Resolved value or null.
13
     */
14
    protected function resolveStoredByName(\ReflectionParameter $param) {
15
        return $this->read($param->getName());
0 ignored issues
show
Bug introduced by
It seems like read() 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

15
        return $this->/** @scrutinizer ignore-call */ read($param->getName());
Loading history...
16
    }
17
18
    /**
19
     * Tries to resolve parameter by its name from factory method with the same name.
20
     *
21
     * @param   \ReflectionParameter  $param  Parameter to be resolved.
22
     * @return  mixed|null                    Resolved value or null.
23
     */
24
    protected function resolveMethodByName(\ReflectionParameter $param) {
25
        return $this->fromMethod($param->getName());
0 ignored issues
show
Bug introduced by
It seems like fromMethod() 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

25
        return $this->/** @scrutinizer ignore-call */ fromMethod($param->getName());
Loading history...
26
    }
27
}