Completed
Push — master ( bd97eb...77fdab )
by Sudar
08:35
created

AddonLicense   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 33
ccs 0
cts 10
cp 0
rs 10
c 0
b 0
f 0
wmc 6
lcom 1
cbo 1

3 Methods

Rating   Name   Duplication   Size   Complexity  
A is_valid() 0 7 3
A get_license_key() 0 7 2
A get_option_name() 0 3 1
1
<?php namespace EmailLog\Addon\License;
2
3
defined( 'ABSPATH' ) || exit; // Exit if accessed directly.
4
5
/**
6
 * EmailLog License.
7
 *
8
 * @since 2.0.0
9
 */
10
class AddonLicense extends BaseLicense {
11
12
	public function is_valid() {
13
		if ( ! $this->license_data instanceof \stdClass || ! isset( $this->license_data->license ) ) {
14
			return false;
15
		}
16
17
		return ( 'valid' === $this->license_data->license );
18
	}
19
20
	/**
21
	 * Get License key.
22
	 *
23
	 * @return null|string License key.
24
	 */
25
	public function get_license_key() {
26
		if ( empty( $this->license_data ) ) {
27
			return parent::get_license_key();
28
		}
29
30
		return $this->license_data->license_key;
31
	}
32
33
	/**
34
	 * Option name in which individual license data is stored.
35
	 * This method should be called only after setting the add-on name.
36
	 *
37
	 * @return string Option name.
38
	 */
39
	protected function get_option_name() {
40
		return 'el_license_' . md5( $this->get_addon_name() );
41
	}
42
}
43