Passed
Push — master ( 5df63f...4c57ea )
by Jean-Christophe
06:08
created

Framework   A

Complexity

Total Complexity 15

Size/Duplication

Total Lines 81
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 15
eloc 23
dl 0
loc 81
ccs 36
cts 36
cp 1
rs 10
c 0
b 0
f 0

15 Methods

Rating   Name   Duplication   Size   Complexity  
A getAction() 0 2 1
A getController() 0 2 1
A hasAdmin() 0 2 1
A getVersion() 0 2 1
A getUrl() 0 2 1
A getRequest() 0 2 1
A getCookies() 0 2 1
A getTranslator() 0 2 1
A getNormalizer() 0 2 1
A getORM() 0 2 1
A getSession() 0 2 1
A getAssets() 0 2 1
A getRouter() 0 2 1
A diBootstrap() 0 5 1
A diSemantic() 0 5 1
1
<?php
2
3
/**
4
 * This class gives access to useful methods or objects of the framework.
5
 * Ubiquity\core
6
 * This class is part of Ubiquity
7
 * @author jcheron <[email protected]>
8
 * @version 1.0.3
9
 *
10
 */
11
namespace Ubiquity\core;
12
13
use Ubiquity\controllers\Startup;
14
use Ubiquity\controllers\Router;
15
use Ubiquity\utils\http\URequest;
16
use Ubiquity\utils\http\USession;
17
use Ubiquity\utils\http\UCookie;
18
use Ubiquity\orm\OrmUtils;
19
use Ubiquity\translation\TranslatorManager;
20
use Ubiquity\contents\normalizers\NormalizersManager;
21
use Ubiquity\assets\AssetsManager;
22
use Ubiquity\controllers\Controller;
23
24
class Framework {
25
	public const version = '2.1.0';
26
27 4
	public static function getVersion() {
28 4
		return self::version;
29
	}
30
31 4
	public static function getController() {
32 4
		return Startup::getController ();
33
	}
34
35 5
	public static function getAction() {
36 5
		return Startup::getAction ();
37
	}
38
39 4
	public static function getUrl() {
40 4
		return \implode ( "/", Startup::$urlParts );
41
	}
42
43 1
	public static function getRouter() {
44 1
		return new Router ();
45
	}
46
47 1
	public static function getORM() {
48 1
		return new OrmUtils ();
49
	}
50
51 1
	public static function getRequest() {
52 1
		return new URequest ();
53
	}
54
55 1
	public static function getSession() {
56 1
		return new USession ();
57
	}
58
59 1
	public static function getCookies() {
60 1
		return new UCookie ();
61
	}
62
63 1
	public static function getTranslator() {
64 1
		return new TranslatorManager ();
65
	}
66
67 1
	public static function getNormalizer() {
68 1
		return new NormalizersManager ();
69
	}
70
71 4
	public static function hasAdmin() {
72 4
		return \class_exists ( "controllers\Admin" );
73
	}
74
75 1
	public static function getAssets() {
76 1
		return new AssetsManager ();
77
	}
78
79
	/**
80
	 * Returns an instance of JsUtils initialized with Semantic (for di injection)
81
	 *
82
	 * @param Controller $controller
83
	 * @param array $options
84
	 * @return \Ajax\php\ubiquity\JsUtils
85
	 */
86 1
	public static function diSemantic($controller, $options = ["defer"=>true,"gc"=>true]) {
87 1
		$jquery = new \Ajax\php\ubiquity\JsUtils ( $options, $controller );
88 1
		$jquery->semantic ( new \Ajax\Semantic () );
89 1
		$jquery->setAjaxLoader ( "<div class=\"ui active centered inline text loader\">Loading</div>" );
90 1
		return $jquery;
91
	}
92
93
	/**
94
	 * Returns an instance of JsUtils initialized with Bootstrap (for di injection)
95
	 *
96
	 * @param Controller $controller
97
	 * @param array $options
98
	 * @return \Ajax\php\ubiquity\JsUtils
99
	 */
100 1
	public static function diBootstrap($controller, $options = ["defer"=>true,"gc"=>true]) {
101 1
		$jquery = new \Ajax\php\ubiquity\JsUtils ( $options, $controller );
102 1
		$jquery->bootstrap ( new \Ajax\Bootstrap () );
103 1
		$jquery->setAjaxLoader ( "<div class=\"ui active centered inline text loader\">Loading</div>" );
104 1
		return $jquery;
105
	}
106
}
107
108