RedirectResolver   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 4
c 0
b 0
f 0
lcom 1
cbo 1
dl 0
loc 25
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setViewEngineConfig() 0 4 1
A resolve() 0 15 3
1
<?php
2
3
namespace App\ViewResolver;
4
5
use Core\View\ViewResolverInterface;
6
use App\ViewEngine\RedirectView;
7
8
class RedirectResolver implements ViewResolverInterface
9
{
10
    private $settings = [];
11
12
    public function setViewEngineConfig(array $settings)
13
    {
14
        $this->settings = $settings;
15
    }
16
17
    public function resolve($viewData)
18
    {
19
        if (is_string($viewData) === false) {
20
            return;
21
        }
22
23
        if (preg_match('/^redirect:(.*)/', $viewData, $url) === 0) {
24
            return;
25
        }
26
27
        $view = new RedirectView($this->settings);
28
        $view->file(trim($url[1]));
29
30
        return $view;
31
    }
32
}
33