Completed
Push — master ( 053e09...4ba1a0 )
by Sudar
02:24
created

BundleLicense::clear()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php namespace EmailLog\License;
2
3
defined( 'ABSPATH' ) || exit; // Exit if accessed directly.
4
5
/**
6
 * BundleLicense Object.
7
 * There can be only one BundleLicence for all the add-ons.
8
 *
9
 * @since 2.0.0
10
 */
11
class BundleLicense extends BaseLicense {
12
13
	protected $addon_name = 'Email Log Bundle';
14
15
	/**
16
	 * Is the license valid?
17
	 *
18
	 * @return bool True if valid, False otherwise.
19
	 */
20
	public function is_valid() {
21
		if ( empty( $this->license_data ) ) {
22
			return false;
23
		}
24
25
		if ( 'valid' === $this->license_data->license ) {
0 ignored issues
show
Unused Code introduced by
This if statement, and the following return statement can be replaced with return 'valid' === $this->license_data->license;.
Loading history...
26
			return true;
27
		}
28
29
		return false;
30
	}
31
32
	/**
33
	 * Return bundle license key.
34
	 *
35
	 * @return string Bundle License key, if found.
36
	 */
37
	public function get_license_key() {
38
		if ( empty( $this->license_data ) ) {
39
			return parent::get_license_key();
40
		}
41
42
		return $this->license_data->bundle_license_key;
43
	}
44
45
	/**
46
	 * The option name in which the bundle license data will be stored.
47
	 *
48
	 * @return string Option name.
49
	 */
50
	protected function get_option_name() {
51
		return 'el_bundle_license';
52
	}
53
54
	/**
55
	 * Get the license key of an add-on from Bundle.
56
	 *
57
	 * @param string $addon_name Add-on name.
58
	 *
59
	 * @return bool|string False if no license key is found, otherwise license key.
60
	 */
61
	public function get_addon_license_key( $addon_name ) {
62
		if ( empty( $this->license_data ) ) {
63
			return false;
64
		}
65
66
		if ( ! isset( $this->license_data->bundled_licenses->{$addon_name} ) ) {
67
			return false;
68
		}
69
70
		return $this->license_data->bundled_licenses->{$addon_name}->license_key;
71
	}
72
}
73