Passed
Push — main ( 8db6c4...70b583 )
by Osvaldo
01:45
created

MiddlewareControlador   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 16
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 9 1
A __construct() 0 3 1
1
<?php
2
namespace app\librerias\controlador;
3
4
use src\contenedorId\Contenedor;
5
use src\FactoryInterface;
6
use src\MiddlewareInterface;
7
use src\PeticionInterface;
8
use const CONTROLADOR_NAMESPACE;
9
10
class MiddlewareControlador implements MiddlewareInterface
11
{
12
    public function __construct(FactoryInterface $Factory)
13
    {
14
        $this->_factory = $Factory;
0 ignored issues
show
Bug Best Practice introduced by
The property _factory does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
15
    }
16
    
17
    public function __invoke(PeticionInterface $peticion, callable $next)
18
    {
19
        $contenedor = new Contenedor();
20
21
        $controlador = $contenedor->obtener(CONTROLADOR_NAMESPACE.$peticion->controlador());
22
23
        call_user_func_array([$controlador,$peticion->metodo()], $peticion->parametros());
24
        
25
        return $next($peticion);
26
    }
27
}
28