GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

FS_Pricing   A
last analyzed

Complexity

Total Complexity 17

Size/Duplication

Total Lines 129
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 129
rs 10
c 0
b 0
f 0
wmc 17
lcom 1
cbo 1

9 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A get_type() 0 3 1
A has_monthly() 0 3 2
A has_annual() 0 3 2
A has_lifetime() 0 3 2
A is_unlimited() 0 3 1
A is_multi_cycle() 0 14 4
A annual_discount_percentage() 0 3 2
A annual_savings() 0 3 2
1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 13 and the first side effect is on line 10.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
	/**
3
	 * @package     Freemius for EDD Add-On
4
	 * @copyright   Copyright (c) 2015, Freemius, Inc.
5
	 * @license     https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
6
	 * @since       1.0.0
7
	 */
8
9
	if ( ! defined( 'ABSPATH' ) ) {
10
		exit;
11
	}
12
13
	class FS_Pricing extends FS_Entity {
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
14
15
		#region Properties
16
17
		/**
18
		 * @var number
19
		 */
20
		public $plan_id;
21
		/**
22
		 * @var int
23
		 */
24
		public $licenses;
25
		/**
26
		 * @var null|float
27
		 */
28
		public $monthly_price;
29
		/**
30
		 * @var null|float
31
		 */
32
		public $annual_price;
33
		/**
34
		 * @var null|float
35
		 */
36
		public $lifetime_price;
37
38
		#endregion Properties
39
40
		/**
41
		 * @param object|bool $pricing
42
		 */
43
		function __construct( $pricing = false ) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
44
			parent::__construct( $pricing );
45
		}
46
47
		static function get_type() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
48
			return 'pricing';
49
		}
50
51
		/**
52
		 * @author Vova Feldman (@svovaf)
53
		 * @since  1.1.8
54
		 *
55
		 * @return bool
56
		 */
57
		function has_monthly() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
58
			return ( is_numeric( $this->monthly_price ) && $this->monthly_price > 0 );
59
		}
60
61
		/**
62
		 * @author Vova Feldman (@svovaf)
63
		 * @since  1.1.8
64
		 *
65
		 * @return bool
66
		 */
67
		function has_annual() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
68
			return ( is_numeric( $this->annual_price ) && $this->annual_price > 0 );
69
		}
70
71
		/**
72
		 * @author Vova Feldman (@svovaf)
73
		 * @since  1.1.8
74
		 *
75
		 * @return bool
76
		 */
77
		function has_lifetime() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
78
			return ( is_numeric( $this->lifetime_price ) && $this->lifetime_price > 0 );
79
		}
80
81
		/**
82
		 * Check if unlimited licenses pricing.
83
		 *
84
		 * @author Vova Feldman (@svovaf)
85
		 * @since  1.1.8
86
		 *
87
		 * @return bool
88
		 */
89
		function is_unlimited() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
90
			return is_null( $this->licenses );
91
		}
92
93
94
		/**
95
		 * Check if pricing has more than one billing cycle.
96
		 *
97
		 * @author Vova Feldman (@svovaf)
98
		 * @since  1.1.8
99
		 *
100
		 * @return bool
101
		 */
102
		function is_multi_cycle() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
103
			$cycles = 0;
104
			if ( $this->has_monthly() ) {
105
				$cycles ++;
106
			}
107
			if ( $this->has_annual() ) {
108
				$cycles ++;
109
			}
110
			if ( $this->has_lifetime() ) {
111
				$cycles ++;
112
			}
113
114
			return $cycles > 1;
115
		}
116
117
		/**
118
		 * Get annual over monthly discount.
119
		 *
120
		 * @author Vova Feldman (@svovaf)
121
		 * @since  1.1.8
122
		 *
123
		 * @return int
124
		 */
125
		function annual_discount_percentage() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
126
			return floor( $this->annual_savings() / ( $this->monthly_price * 12 * ( $this->is_unlimited() ? 1 : $this->licenses ) ) * 100 );
127
		}
128
129
		/**
130
		 * Get annual over monthly savings.
131
		 *
132
		 * @author Vova Feldman (@svovaf)
133
		 * @since  1.1.8
134
		 *
135
		 * @return float
136
		 */
137
		function annual_savings() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
138
			return ( $this->monthly_price * 12 - $this->annual_price ) * ( $this->is_unlimited() ? 1 : $this->licenses );
139
		}
140
141
	}