Completed
Push — master ( 220ceb...ab9a78 )
by Sinnarasa
02:32
created

ClosureDispatcher::call()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 6
Code Lines 4

Duplication

Lines 2
Ratio 33.33 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 2
loc 6
rs 9.4285
cc 3
eloc 4
nc 4
nop 0
1
<?php
2
3
namespace JetFire\Routing\Dispatcher;
4
5
6
use JetFire\Routing\Route;
7
8
/**
9
 * Class ClosureDispatcher
10
 * @package JetFire\Routing\Dispatcher
11
 */
12
class ClosureDispatcher implements DispatcherInterface
13
{
14
15
    /**
16
     * @var Route
17
     */
18
    private $route;
19
20
    /**
21
     * @param Route $route
22
     */
23
    public function __construct(Route $route)
24
    {
25
        $this->route = $route;
26
    }
27
28
    /**
29
     * @description call anonymous function
30
     *
31
     */
32
    public function call()
33
    {
34 View Code Duplication
        if ($this->route->getResponse('code') == 202) $this->route->setResponse(['code' => 200, 'message' => 'OK', 'type' => 'text/html']);
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
35
        $params = ($this->route->getParameters() == '') ? [] : $this->route->getParameters();
36
        echo call_user_func_array($this->route->getTarget('closure'), $params);
37
    }
38
39
}
40