Passed
Push — master ( c6150b...ef80b0 )
by Mihail
05:01
created

ActionDeleteRoute   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 21
rs 10
c 0
b 0
f 0
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A deleteRoute() 0 14 3
1
<?php
2
3
namespace Apps\Controller\Admin\Main;
4
5
6
use Apps\Model\Admin\Main\EntityDeleteRoute;
7
use Ffcms\Core\Arch\View;
8
use Ffcms\Core\Helper\Type\Str;
9
use Ffcms\Core\Network\Request;
10
use Ffcms\Core\Network\Response;
11
12
/**
13
 * Trait ActionDeleteRoute
14
 * @package Apps\Controller\Admin\Main
15
 * @property Request $request
16
 * @property Response $response
17
 * @property View $view
18
 */
19
trait ActionDeleteRoute
20
{
21
    /**
22
     * Delete existing route action
23
     * @return string|null
24
     * @throws \Ffcms\Core\Exception\SyntaxException
25
     */
26
    public function deleteRoute(): ?string
27
    {
28
        $type = (string)$this->request->query->get('type');
29
        $loader = (string)$this->request->query->get('loader');
30
        $source = Str::lowerCase((string)$this->request->query->get('path'));
31
32
        $model = new EntityDeleteRoute($type, $loader, $source);
33
        if ($model->send() && $model->validate()) {
34
            $model->make();
35
            return $this->view->render('main/delete_route_save');
36
        }
37
38
        return $this->view->render('main/delete_route', [
39
            'model' => $model
40
        ]);
41
    }
42
}