Passed
Push — master ( a357e7...195a07 )
by Anton
04:22 queued 01:11
created

Basic   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 3
dl 0
loc 31
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A loader() 0 4 1
B init() 0 19 5
1
<?php
2
3
namespace Modules\Extend\Utils\Extension {
4
5
	use Modules\Extend, Exception, Cookie, Request;
6
7
	abstract class Basic extends Extend\Utils\Extension {
8
9
		# Create new loader
10
11
		public static function loader(string $section, bool $load_all = true) {
12
13
			return new static::$loader_class($section, $load_all);
14
		}
15
16
		# Init extensions list
17
18
		public static function init(string $section) {
19
20
			static::$loader = new static::$loader_class($section, false);
21
22
			# Throw error if no extensions found
23
24
			if (false === static::$loader->active()) throw new static::$exception_class;
25
26
			# Activate user defined extension
27
28
			if (static::$selectable[$section]) {
29
30
				$name = static::$name; $param = static::$param[static::$loader->section()];
31
32
				if (static::$loader->activate(Request::get($name)) || static::$loader->activate(Cookie::get($param)))
33
34
					Cookie::set($param, static::$loader->data('name'), static::$cookie_expires);
35
			}
36
		}
37
	}
38
}
39