Auto   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 114
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 9
eloc 71
dl 0
loc 114
c 0
b 0
f 0
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A dependencies() 0 73 1
A debug_page() 0 4 2
A load() 0 14 1
A dependencie() 0 10 5
1
<?php
2
3
/**
4
 * © 2018 - Phoponent
5
 * Author: Nicolas Choquet
6
 * Email: [email protected]
7
 * LICENSE GPL ( GNU General Public License )
8
 */
9
10
namespace phoponent\framework\loading;
11
12
13
use phoponent\framework\static_classe\debug;
14
15
class Auto {
16
    protected static $dependencies = [];
17
18
    private static function debug_page() {
19
        ini_set('display_errors', 'off');
20
        if(debug::get_debug()) {
21
            ini_set('display_errors', 'on');
22
        }
23
    }
24
25
	public static function load() {
26
		require_once 'traits/static_class.php';
27
        require_once 'classes/debug.php';
28
        self::debug_page();
29
		require_once 'traits/view.php';
30
		require_once 'traits/model.php';
31
		require_once 'traits/service.php';
32
		require_once 'traits/command.php';
33
		require_once 'classes/regexp.php';
34
		require_once 'classes/xphp.php';
35
		require_once 'classes/xphp_tag.php';
36
		require_once 'classes/command.php';
37
38
		require_once 'classes/index.php';
39
	}
40
41
	public static function dependencies() {
42
		self::$dependencies = [
43
		    // Framework
44
45
            // Traits
46
            'traits' => [
47
                'static_class' => [
48
                    'path' => __DIR__.'/traits/static_class.php',
49
                    'class' => \phoponent\framework\traits\static_class::class,
50
                ],
51
                'view' => [
52
                    'path' => __DIR__.'/traits/view.php',
53
                    'class' => \phoponent\framework\traits\view::class,
54
                ],
55
                'model' => [
56
                    'path' => __DIR__.'/traits/model.php',
57
                    'class' => \phoponent\framework\traits\model::class,
58
                ],
59
                'service' => [
60
                    'path' => __DIR__.'/traits/service.php',
61
                    'class' => \phoponent\framework\traits\service::class,
62
                ],
63
                'command' => [
64
                    'path' => __DIR__.'/traits/command.php',
65
                    'class' => \phoponent\framework\traits\command::class,
66
                ],
67
            ],
68
69
            // Classes
70
            'classes' => [
71
                'regexp' => [
72
                    'path' => __DIR__.'/classes/regexp.php',
73
                    \phoponent\framework\static_classe\regexp::class,
74
                ],
75
                'phoponent' => [
76
                    'path' => __DIR__.'/classes/xphp.php',
77
                    \phoponent\framework\static_classe\xphp::class,
78
                ],
79
                'component' => [
80
                    'path' => __DIR__.'/classes/xphp_tag.php',
81
                    \phoponent\framework\classe\xphp_tag::class,
82
                ],
83
                'class_command' => [
84
                    'path' => __DIR__.'/classes/command.php',
85
                    \phoponent\framework\static_classe\command::class,
86
                ],
87
             ],
88
89
            // Services
90
            'services' => [
91
                'json_reader' => [
92
                    'path' => __DIR__.'/services/json_reader.php',
93
                    'class' => \phoponent\framework\service\json_reader::class,
94
                ],
95
                'json_writer' => [
96
                    'path' => __DIR__.'/services/json_writer.php',
97
                    'class' => \phoponent\framework\service\json_writer::class,
98
                ],
99
                'translation' => [
100
                    'path' => __DIR__.'/services/translation.php',
101
                    'class' => \phoponent\framework\service\translation::class,
102
            ],
103
            ],
104
105
            // Commandes
106
            'commands' => [
107
                'help' =>  [
108
                    'path' => __DIR__.'/../commands/help.php',
109
                    'class' => \phoponent\framework\command\help::class,
110
                ],
111
                'make' => [
112
                    'path' => __DIR__.'/../commands/make.php',
113
                    'class' => \phoponent\framework\command\make::class,
114
                ]
115
            ],
116
		];
117
	}
118
119
	public static function dependencie($type, $name = null) {
120
	    self::dependencies();
121
	    if($name) {
122
	        if(isset(self::$dependencies[$type][$name]) && is_file(self::$dependencies[$type][$name]['path'])) {
123
	            require_once self::$dependencies[$type][$name]['path'];
124
	            return self::$dependencies[$type][$name]['class'];
125
            }
126
            return null;
127
        }
128
	    return isset(self::$dependencies[$type]) ? self::$dependencies[$type] : null;
129
    }
130
}