Test Failed
Push — master ( 79af4d...00f9a5 )
by Fran
02:26
created

Admin::staticAdminLogon()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 3.3332

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 3
eloc 6
c 2
b 0
f 0
nc 3
nop 0
dl 0
loc 9
ccs 4
cts 6
cp 0.6667
crap 3.3332
rs 10
1
<?php
2
3
namespace PSFS\controller\base;
4
5
use PSFS\base\exception\UserAuthException;
6
use PSFS\base\types\AuthAdminController;
7
use PSFS\controller\UserController;
8
use PSFS\services\AdminServices;
9
10
/**
11
 * Class Admin
12
 * @package PSFS\controller
13
 * @domain ROOT
14
 */
15
abstract class Admin extends AuthAdminController
16
{
17
    const DOMAIN = 'ROOT';
18
19
    /**
20
     * @Injectable
21
     * @var \PSFS\base\config\Config Configuration service
22
     */
23
    protected $config;
24
    /**
25
     * @Injectable
26
     * @var \PSFS\services\AdminServices Admin service
27
     */
28
    protected $srv;
29
30
    /**
31
     * Método estático de login de administrador
32
     * @return string HTML
33
     * @throws UserAuthException
34
     * @throws \PSFS\base\exception\GeneratorException
35
     */
36 1
    public static function staticAdminLogon()
37
    {
38 1
        if (self::isTest()) {
39
            throw new UserAuthException();
40
        }
41 1
        if (file_exists(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json')) {
42
            return AdminServices::getInstance()->setAdminHeaders();
43
        } else {
44 1
            return UserController::showAdminManager();
45
        }
46
    }
47
48
    /**
49
     * Método que gestiona el menú de administración
50
     * @GET
51
     * @route /admin
52
     * @visible false
53
     * @return string|null
54
     */
55
    public function index()
56
    {
57
        return $this->render("index.html.twig");
58
    }
59
60
}
61