Completed
Pull Request — develop (#1350)
by Naveen
03:25
created

Default_Loader   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 41
rs 10
c 0
b 0
f 0
wmc 2
lcom 1
cbo 1

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
init_all_dependencies() 0 1 ?
get_feature_slug() 0 1 ?
get_feature_default_value() 0 1 ?
A init_feature() 0 9 1
1
<?php
2
/**
3
 * This abstract class loads the feature to registry.
4
 * @since 3.31.0
5
 * @author Naveen Muthusamy <[email protected]>
6
 */
7
8
namespace Wordlift\Common\Loader;
9
10
use Wordlift\Features\Features_Registry;
11
12
abstract class Default_Loader implements Loader {
13
	/**
14
	 * @var Features_Registry
15
	 */
16
	private $features_registry;
17
18
	/**
19
	 * Default_Loader constructor.
20
	 */
21
	public function __construct() {
22
		$this->features_registry = Features_Registry::get_instance();
23
	}
24
25
	/**
26
	 * Initialize all the dependencies needed by the feature inside this method.
27
	 * @return void
28
	 */
29
	public abstract function init_all_dependencies();
30
31
	protected abstract function get_feature_slug();
32
33
	/**
34
	 * @return bool true if the feature wants to be enabled by default
35
	 */
36
	protected abstract function get_feature_default_value();
37
38
	/**
39
	 * Register feature to registry.
40
	 */
41
	public function init_feature() {
42
43
		$this->features_registry->register_feature_from_slug(
44
			$this->get_feature_slug(),
45
			$this->get_feature_default_value(),
46
			array( $this, 'init_all_dependencies' )
47
		);
48
49
	}
50
51
52
}