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.
Completed
Push — master ( bb6361...a2a740 )
by Brad
04:28
created

FS_Entity::__construct()   B

Complexity

Conditions 5
Paths 4

Size

Total Lines 13
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 5
eloc 8
nc 4
nop 1
dl 0
loc 13
rs 8.8571
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 23 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.3
7
	 */
8
9
	if ( ! defined( 'ABSPATH' ) ) {
10
		exit;
11
	}
12
13
	/**
14
	 * Get object's public variables.
15
	 *
16
	 * @author Vova Feldman (@svovaf)
17
	 * @since  1.0.0
18
	 *
19
	 * @param object $object
20
	 *
21
	 * @return array
22
	 */
23
	function fs_get_object_public_vars( $object ) {
24
		return get_object_vars( $object );
25
	}
26
27
	class 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...
28
		/**
29
		 * @var number
30
		 */
31
		public $id;
32
		/**
33
		 * @var string Datetime value in 'YYYY-MM-DD HH:MM:SS' format.
34
		 */
35
		public $updated;
36
		/**
37
		 * @var string Datetime value in 'YYYY-MM-DD HH:MM:SS' format.
38
		 */
39
		public $created;
40
41
		/**
42
		 * @param bool|object $entity
43
		 */
44
		function __construct( $entity = 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...
45
            if ( ! ( $entity instanceof stdClass ) && ! ( $entity instanceof FS_Entity ) ) {
46
                return;
47
            }
48
49
			$props = fs_get_object_public_vars( $this );
50
51
			foreach ( $props as $key => $def_value ) {
52
				$this->{$key} = isset( $entity->{$key} ) ?
53
					$entity->{$key} :
54
					$def_value;
55
			}
56
		}
57
58
		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...
59
			return 'type';
60
		}
61
62
		/**
63
		 * @author Vova Feldman (@svovaf)
64
		 * @since  1.0.6
65
		 *
66
		 * @param FS_Entity $entity1
67
		 * @param FS_Entity $entity2
68
		 *
69
		 * @return bool
70
		 */
71
		static function equals( $entity1, $entity2 ) {
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...
72
			if ( is_null( $entity1 ) && is_null( $entity2 ) ) {
73
				return true;
74
			} else if ( is_object( $entity1 ) && is_object( $entity2 ) ) {
75
				return ( $entity1->id == $entity2->id );
76
			} else if ( is_object( $entity1 ) ) {
77
				return is_null( $entity1->id );
78
			} else {
79
				return is_null( $entity2->id );
80
			}
81
		}
82
83
		private $_is_updated = false;
84
85
		/**
86
		 * Update object property.
87
		 *
88
		 * @author Vova Feldman (@svovaf)
89
		 * @since  1.0.9
90
		 *
91
		 * @param  string|array[string]mixed $key
0 ignored issues
show
Documentation introduced by
The doc-type string|array[string]mixed could not be parsed: Expected "]" at position 4, but found "string". (view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
92
		 * @param string|bool $val
93
		 *
94
		 * @return bool
95
		 */
96
		function update( $key, $val = 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...
97
			if ( ! is_array( $key ) ) {
98
				$key = array( $key => $val );
99
			}
100
101
			$is_updated = false;
102
103
			foreach ( $key as $k => $v ) {
104
				if ( $this->{$k} === $v ) {
105
					continue;
106
				}
107
108
				if ( ( is_string( $this->{$k} ) && is_numeric( $v ) ||
109
				       ( is_numeric( $this->{$k} ) && is_string( $v ) ) ) &&
110
				     $this->{$k} == $v
111
				) {
112
					continue;
113
				}
114
115
				// Update value.
116
				$this->{$k} = $v;
117
118
				$is_updated = true;
119
			}
120
121
			$this->_is_updated = $is_updated;
122
123
			return $is_updated;
124
		}
125
126
		/**
127
		 * Checks if entity was updated.
128
		 *
129
		 * @author Vova Feldman (@svovaf)
130
		 * @since  1.0.9
131
		 *
132
		 * @return bool
133
		 */
134
		function is_updated() {
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...
135
			return $this->_is_updated;
136
		}
137
138
		/**
139
		 * @param $id
140
		 *
141
		 * @author Vova Feldman (@svovaf)
142
		 * @since  1.1.2
143
		 *
144
		 * @return bool
145
		 */
146
		static function is_valid_id($id){
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
			return is_numeric($id);
148
		}
149
	}