Code Duplication    Length = 26-26 lines in 2 locations

src/resolvers/ContainerTypeResolver.php 1 location

@@ 17-42 (lines=26) @@
14
 *
15
 * @see https://github.com/container-interop/container-interop
16
 */
17
class ContainerTypeResolver implements Resolver
18
{
19
    /**
20
     * @var ContainerInterface
21
     */
22
    private $container;
23
24
    /**
25
     * @param ContainerInterface $container
26
     */
27
    public function __construct(ContainerInterface $container)
28
    {
29
        $this->container = $container;
30
    }
31
32
    public function resolve(ReflectionParameter $param, $next)
33
    {
34
        $type = TypeReflector::getTypeName($param);
35
36
        if ($type !== null && $this->container->has($type)) {
37
            return $this->container->get($type);
38
        }
39
40
        return $next($param);
41
    }
42
}
43

src/resolvers/TypeMapResolver.php 1 location

@@ 12-37 (lines=26) @@
9
/**
10
 * Resolves type-hints against a map where parameter type => value
11
 */
12
class TypeMapResolver implements Resolver
13
{
14
    /**
15
     * @var array
16
     */
17
    private $map;
18
19
    /**
20
     * @param array $map map where fully-qualified class-name => parameter value
21
     */
22
    public function __construct($map)
23
    {
24
        $this->map = $map;
25
    }
26
27
    public function resolve(ReflectionParameter $param, $next)
28
    {
29
        $type = TypeReflector::getTypeName($param);
30
31
        if ($type !== null && array_key_exists($type, $this->map)) {
32
            return $this->map[$type];
33
        }
34
35
        return $next($param);
36
    }
37
}
38