Passed
Push — master ( 54313c...3e1de2 )
by Fran
03:22
created

Admin   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 6

Test Coverage

Coverage 20%

Importance

Changes 0
Metric Value
dl 0
loc 56
ccs 3
cts 15
cp 0.2
rs 10
c 0
b 0
f 0
wmc 4
lcom 0
cbo 6

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getMenu() 0 3 1
A index() 0 3 1
A staticAdminLogon() 0 14 2
1
<?php
2
3
namespace PSFS\controller\base;
4
5
use PSFS\base\config\Config;
6
use PSFS\base\config\LoginForm;
7
use PSFS\base\Router;
8
use PSFS\base\Template;
9
use PSFS\base\types\AuthAdminController;
10
use PSFS\services\AdminServices;
11
12
/**
13
 * Class Admin
14
 * @package PSFS\controller
15
 * @domain ROOT
16
 */
17
class Admin extends AuthAdminController{
18
19
    const DOMAIN = 'ROOT';
20
21
    /**
22
     * @Inyectable
23
     * @var \PSFS\base\config\Config Configuration service
24
     */
25
    protected $config;
26
    /**
27
     * @Inyectable
28
     * @var \PSFS\services\AdminServices Admin service
29
     */
30
    protected $srv;
31
32
    /**
33
     * Wrapper de asignación de los menus
34
     * @return array
35
     */
36
    protected function getMenu() {
37
        return Router::getInstance()->getAdminRoutes();
38
    }
39
40
    /**
41
     * Método estático de login de administrador
42
     * @param string $route
0 ignored issues
show
Documentation introduced by
Should the type for parameter $route not be string|null?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
43
     * @return string HTML
0 ignored issues
show
Documentation introduced by
Should the return type not be string|null?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
44
     * @throws \PSFS\base\exception\FormException
45
     */
46 1
    public static function staticAdminLogon($route = null) {
47 1
        if('login' !== Config::getInstance()->get('admin_login')) {
48 1
            return AdminServices::getInstance()->setAdminHeaders();
49
        } else {
50
            $form = new LoginForm();
51
            $form->setData(array("route" => $route));
52
            $form->build();
53
            $tpl = Template::getInstance();
54
            $tpl->setPublicZone(true);
55
            return $tpl->render("login.html.twig", array(
56
                'form' => $form,
57
            ));
58
        }
59
    }
60
61
    /**
62
     * Método que gestiona el menú de administración
63
     * @GET
64
     * @route /admin
65
     * @visible false
66
     * @return string|null
67
     */
68
    public function index() {
69
        return $this->render("index.html.twig");
70
    }
71
72
}
73