Completed
Push — master ( 5841c7...d52f43 )
by Sudar
03:55
created

UIManager   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 63
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 15%

Importance

Changes 4
Bugs 0 Features 1
Metric Value
c 4
b 0
f 1
dl 0
loc 63
ccs 3
cts 20
cp 0.15
rs 10
wmc 6
lcom 1
cbo 3

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A load() 0 12 3
A initialize_components() 0 3 1
A initialize_pages() 0 4 1
1
<?php namespace EmailLog\Core\UI;
2
3
use EmailLog\Core\UI\Component\PluginListEnhancer;
4
5
/**
6
 * Admin UI Manager.
7
 *
8
 * @since 2.0
9
 */
10
class UIManager {
11
12
	/**
13
	 * @var string Plugin filename.
14
	 */
15
	protected $plugin_file;
16
17
	/**
18
	 * @var array UI Component List.
19
	 */
20
	protected $components = array();
21
22
	/**
23
	 * @var array Admin pages.
24
	 */
25
	protected $pages = array();
26
27
	/**
28
	 * Initialize the plugin.
29
	 */
30 2
	public function __construct( $file ) {
31 2
		$this->plugin_file = $file;
32 2
	}
33
34
	/**
35
	 * Load all components and setup hooks.
36
	 */
37
	public function load() {
38
		$this->initialize_components();
39
		$this->initialize_pages();
40
41
		foreach ( $this->components as $component ) {
42
			$component->load();
43
		}
44
45
		foreach ( $this->pages as $page ) {
46
			$page->load();
47
		}
48
	}
49
50
	/**
51
	 * Initialize UI component Objects.
52
	 *
53
	 * This method may be overwritten in tests.
54
	 *
55
	 * @access protected
56
	 */
57
	protected function initialize_components() {
58
		$this->components['plugin_list_enhancer'] = new PluginListEnhancer( $this->plugin_file );
59
	}
60
61
	/**
62
	 * Initialize Admin page Objects.
63
	 *
64
	 * This method may be overwritten in tests.
65
	 *
66
	 * @access protected
67
	 */
68
	protected function initialize_pages() {
69
		$this->pages['log_list_page']   = new Page\LogListPage( $this->plugin_file );
70
		$this->pages['addon_list_page'] = new Page\AddonListPage( $this->plugin_file );
71
	}
72
}