Completed
Push — dev/6.0.0 ( aa3d2c...13ef32 )
by Sudar
15:08
created

BaseAddon::get_info()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace BulkWP\BulkDelete\Core\Addon;
4
5
use BD_License_Handler;
6
7
defined( 'ABSPATH' ) || exit; // Exit if accessed directly.
8
9
/**
10
 * Encapsulates the logic for a add-on.
11
 *
12
 * @since 6.0.0
13
 */
14
abstract class BaseAddon {
15
	/**
16
	 * Details of the Add-on.
17
	 *
18
	 * @var \BulkWP\BulkDelete\Core\Addon\AddonInfo
19
	 */
20
	protected $addon_info;
21
22
	/**
23
	 * Handler for license.
24
	 *
25
	 * @var \BD_License_Handler
26
	 */
27
	protected $license_handler;
28
29
	/**
30
	 * Initialize and setup variables.
31
	 *
32
	 * @return void
33
	 */
34
	abstract protected function initialize();
35
36
	/**
37
	 * Register the add-on.
38
	 *
39
	 * This method will be called in the `bd_loaded` hook.
40
	 *
41
	 * @return void
42
	 */
43
	abstract public function register();
44
45
	/**
46
	 * Create a new instance of the add-on.
47
	 *
48
	 * @param \BulkWP\BulkDelete\Core\Addon\AddonInfo $addon_info Add-on Details.
49
	 */
50
	public function __construct( $addon_info ) {
51
		$this->addon_info = $addon_info;
52
53
		$this->initialize();
54
		$this->setup_license_handler();
55
	}
56
57
	/**
58
	 * Get details about the add-on.
59
	 *
60
	 * @return \BulkWP\BulkDelete\Core\Addon\AddonInfo Add-on Info.
61
	 */
62
	public function get_info() {
63
		return $this->addon_info;
64
	}
65
66
	/**
67
	 * Setup License Handler.
68
	 *
69
	 * TODO: Need this to be refactored.
70
	 */
71
	protected function setup_license_handler() {
72
		$this->license_handler = new BD_License_Handler(
73
			$this->addon_info->get_name(),
74
			$this->addon_info->get_code(),
75
			$this->addon_info->get_version(),
76
			$this->addon_info->get_root_file(),
77
			$this->addon_info->get_author()
78
		);
79
	}
80
}
81