Completed
Pull Request — develop (#1350)
by
unknown
03:32
created

Default_Loader::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
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
}