Completed
Push — master ( f6e733...e82db7 )
by Park Jong-Hun
03:41
created

RedirectResolver::resolve()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 15
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 15
rs 9.4285
cc 3
eloc 8
nc 3
nop 1
1
<?php
2
3
namespace App\ViewResolver;
4
5
use Core\ViewResolverInterface;
6
use App\ViewEngine\Redirect;
7
8
class RedirectResolver implements ViewResolverInterface
9
{
10
11
    private $settings = [];
12
13
    public function setViewEngineConfig(array $settings)
14
    {
15
        $this->settings = $settings;
16
    }
17
18
    public function resolve($viewData)
19
    {
20
        if (is_string($viewData) === false) {
21
            return;
22
        }
23
24
        if (preg_match('/redirect:(.*)/', $viewData, $url) === 0) {
25
            return;
26
        }
27
28
        $view = new Redirect($this->settings);
29
        $view->file(trim($url[1]));
30
31
        return $view;
32
    }
33
}
34