App::load()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
class App{
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
4
5
    private $settings = array();
6
7
    private static $_instance = null;
8
9
    private function __construct(){
10
	// приватный конструктор ограничивает реализацию getInstance ()
11
    }
12
13
    protected function __clone(){
14
	// ограничивает клонирование объекта
15
    }
16
17
    /**
18
     * Вызов модуля
19
     * @param type $name
20
     * @param array $params
21
     * @return string
22
     */
23
    public static function getModule($name, array $params = []){
24
	$DI		 = self::getInstance()->load("DI");
25
	$debugbar	 = $DI->get(DebugBar\StandardDebugBar::class);
26
	$debugbar['messages']->debug(sprintf('App::getModule %s, with params %s', $name, json_encode($params)));
27
	$debugbar['time']->startMeasure($name, 'Load module ' . $name);
28
	$module		 = $DI->get($name);
29
	$result		 = $module->setParams($params)->process();
30
	$debugbar['time']->stopMeasure($name);
31
	return $result;
32
    }
33
34
    public static function getInstance(){
35
	if(is_null(self::$_instance)){
36
	    self::$_instance = new self();
37
	}
38
	return self::$_instance;
39
    }
40
41
    public function import($key, $value){
42
	$this->settings[$key] = $value;
43
    }
44
45
    public function load($key){
46
	return $this->settings[$key];
47
    }
48
}
49