Completed
Push — master ( 69a4a0...53baee )
by Sudar
16:12 queued 06:06
created

BundleLicense::get_addon_license_key()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
cc 3
eloc 5
nc 3
nop 1
dl 0
loc 10
ccs 0
cts 8
cp 0
crap 12
rs 10
c 0
b 0
f 0
1
<?php namespace EmailLog\Addon\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
	/**
14
	 * For Bundle the add-on name is hardcoded.
15
	 *
16
	 * @var string Add-on name.
17
	 */
18
	protected $addon_name = 'Email Log Bundle';
19
20
	public function get_renewal_link() {
21
		$renewal_link = parent::get_renewal_link();
22
23
		return $renewal_link . '&utm_content=BL';
24
	}
25
26
	/**
27
	 * Return bundle license key.
28
	 *
29
	 * @return string Bundle License key, if found.
30
	 */
31
	public function get_license_key() {
32
		if ( empty( $this->license_data ) ) {
33
			return parent::get_license_key();
34
		}
35
36
		return $this->license_data->bundle_license_key;
37
	}
38
39
	/**
40
	 * The option name in which the bundle license data will be stored.
41
	 *
42
	 * @return string Option name.
43
	 */
44
	protected function get_option_name() {
45
		return 'el_bundle_license';
46
	}
47
48
	/**
49
	 * Get the license key of an add-on from Bundle.
50
	 *
51
	 * @param string $addon_name Add-on name.
52
	 *
53
	 * @return bool|string False if no license key is found, otherwise license key.
54
	 */
55
	public function get_addon_license_key( $addon_name ) {
56
		if ( empty( $this->license_data ) ) {
57
			return false;
58
		}
59
60
		if ( ! isset( $this->license_data->bundled_licenses->{$addon_name} ) ) {
61
			return false;
62
		}
63
64
		return $this->license_data->bundled_licenses->{$addon_name}->license_key;
65
	}
66
67
	/**
68
	 * Is the bundle license a lifetime license.
69
	 *
70
	 * @since 2.4.1
71
	 *
72
	 * @return bool True if it is a lifetime license, False otherwise.
73
	 */
74
	public function is_lifetime_license() {
75
		if ( empty( $this->license_data ) || ! isset( $this->license_data->expires ) ) {
76
			return false;
77
		}
78
79
		return ( false === $this->license_data->expires );
80
	}
81
}
82