Passed
Push — main ( bd30b4...b6e144 )
by Rafael
11:59
created

Loader   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 19
c 1
b 0
f 0
dl 0
loc 33
rs 10
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 26 3
1
<?php
2
/**
3
 * Alxarafe. Development of PHP applications in a flash!
4
 * Copyright (C) 2018 Alxarafe <[email protected]>
5
 */
6
7
namespace Alxarafe\Core\Helpers;
8
9
use Alxarafe\Controllers\EditConfig;
10
use Alxarafe\Core\Singletons\Config;
11
use Alxarafe\Core\Singletons\Debug;
12
use Alxarafe\Core\Singletons\FlashMessages;
13
use Alxarafe\Core\Singletons\Logger;
14
use Alxarafe\Core\Singletons\PhpFileCache;
15
use Alxarafe\Core\Singletons\RegionalInfo;
16
use Alxarafe\Core\Singletons\Render;
17
use Alxarafe\Core\Singletons\Session;
18
use Alxarafe\Core\Singletons\Translator;
19
use Alxarafe\Database\YamlSchema;
20
use Alxarafe\Database\Schema;
21
22
/**
23
 * Class Loader, load all globals utilities.
24
 *
25
 * @package Alxarafe\Core\Base
26
 */
27
28
/**
29
 * Class Loader
30
 *
31
 * Inicializa las clases globales
32
 *
33
 * @author  Rafael San José Tovar <[email protected]>
34
 * @version 2023.0115
35
 *
36
 * @package Alxarafe\Core\Helpers
37
 */
38
class Loader
39
{
40
    /**
41
     * Constructor de Loader
42
     *
43
     * @throws \DebugBar\DebugBarException
44
     */
45
    public function __construct()
46
    {
47
        new Globals();
48
        new Config();
49
        new Session();
50
        new FlashMessages();
51
        new RegionalInfo();
52
        new Logger();
53
        new Debug();
54
        new Translator();
55
        new Render();
56
        new PhpFileCache();
57
58
        if (!Config::connectToDatabase()) {
59
            FlashMessages::setError(Translator::trans('database-connection-error'));
60
            $run = new EditConfig();
61
            $run->main();
62
            die();
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
63
        }
64
65
        // TODO: Sólo debería de limpiarse caché al activar y desactivar un plugin, o a demanda.
66
        //       Pero en modo de depuración, debería de limpiarse para actualizar los cambios en las tablas.
67
        if (!YamlSchema::clearYamlCache()) {
68
            die('No se ha podido eliminar la caché');
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
69
        }
70
        Schema::checkDatabaseStructure();
71
    }
72
}
73