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_Plan_Manager::get_trial_plans()   A
last analyzed

Complexity

Conditions 5
Paths 2

Size

Total Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 5
nc 2
nop 1
dl 0
loc 16
rs 9.4222
c 0
b 0
f 0
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
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.6
7
	 */
8
9
	if ( ! defined( 'ABSPATH' ) ) {
10
		exit;
11
	}
12
13
	class FS_Plan_Manager {
0 ignored issues
show
Coding Style introduced by
Since you have declared the constructor as private, maybe you should also declare the class as final.
Loading history...
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
		 * @var FS_Plan_Manager
16
		 */
17
		private static $_instance;
18
19
		/**
20
		 * @return FS_Plan_Manager
21
		 */
22
		static function instance() {
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...
23
			if ( ! isset( self::$_instance ) ) {
24
				self::$_instance = new FS_Plan_Manager();
25
			}
26
27
			return self::$_instance;
28
		}
29
30
		private function __construct() {
31
		}
32
33
		/**
34
		 * @param FS_Plugin_License[] $licenses
35
		 *
36
		 * @return bool
37
		 */
38
		function has_premium_license( $licenses ) {
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...
39
			if ( is_array( $licenses ) ) {
40
				/**
41
				 * @var FS_Plugin_License[] $licenses
42
				 */
43
				foreach ( $licenses as $license ) {
44
					if ( ! $license->is_utilized() && $license->is_features_enabled() ) {
45
						return true;
46
					}
47
				}
48
			}
49
50
			return false;
51
		}
52
53
		/**
54
		 * Check if plugin has any paid plans.
55
		 *
56
		 * @author Vova Feldman (@svovaf)
57
		 * @since  1.0.7
58
		 *
59
		 * @param FS_Plugin_Plan[] $plans
60
		 *
61
		 * @return bool
62
		 */
63
		function has_paid_plan( $plans ) {
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...
64
			if ( ! is_array( $plans ) || 0 === count( $plans ) ) {
65
				return false;
66
			}
67
68
			/**
69
			 * @var FS_Plugin_Plan[] $plans
70
			 */
71
			for ( $i = 0, $len = count( $plans ); $i < $len; $i ++ ) {
72
				if ( ! $plans[ $i ]->is_free() ) {
73
					return true;
74
				}
75
			}
76
77
			return false;
78
		}
79
80
		/**
81
		 * Check if plugin has any free plan, or is it premium only.
82
		 *
83
		 * Note: If no plans configured, assume plugin is free.
84
		 *
85
		 * @author Vova Feldman (@svovaf)
86
		 * @since  1.0.7
87
		 *
88
		 * @param FS_Plugin_Plan[] $plans
89
		 *
90
		 * @return bool
91
		 */
92
		function has_free_plan( $plans ) {
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...
93
			if ( ! is_array( $plans ) || 0 === count( $plans ) ) {
94
				return true;
95
			}
96
97
			/**
98
			 * @var FS_Plugin_Plan[] $plans
99
			 */
100
			for ( $i = 0, $len = count( $plans ); $i < $len; $i ++ ) {
101
				if ( $plans[ $i ]->is_free() ) {
102
					return true;
103
				}
104
			}
105
106
			return false;
107
		}
108
109
		/**
110
		 * Find all plans that have trial.
111
		 *
112
		 * @author Vova Feldman (@svovaf)
113
		 * @since  1.0.9
114
		 *
115
		 * @param FS_Plugin_Plan[] $plans
116
		 *
117
		 * @return FS_Plugin_Plan[]
118
		 */
119
		function get_trial_plans( $plans ) {
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...
120
			$trial_plans = array();
121
122
			if ( is_array( $plans ) && 0 < count( $plans ) ) {
123
				/**
124
				 * @var FS_Plugin_Plan[] $plans
125
				 */
126
				for ( $i = 0, $len = count( $plans ); $i < $len; $i ++ ) {
127
					if ( $plans[ $i ]->has_trial() ) {
128
						$trial_plans[] = $plans[ $i ];
129
					}
130
				}
131
			}
132
133
			return $trial_plans;
134
		}
135
136
		/**
137
		 * Check if plugin has any trial plan.
138
		 *
139
		 * @author Vova Feldman (@svovaf)
140
		 * @since  1.0.9
141
		 *
142
		 * @param FS_Plugin_Plan[] $plans
143
		 *
144
		 * @return bool
145
		 */
146
		function has_trial_plan( $plans ) {
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...
147
			if ( ! is_array( $plans ) || 0 === count( $plans ) ) {
148
				return true;
149
			}
150
151
			/**
152
			 * @var FS_Plugin_Plan[] $plans
153
			 */
154
			for ( $i = 0, $len = count( $plans ); $i < $len; $i ++ ) {
155
				if ( $plans[ $i ]->has_trial() ) {
156
					return true;
157
				}
158
			}
159
160
			return false;
161
		}
162
	}