/var/www/hkosl.com/aga/wp-content/plugins/foogallery/freemius/includes/entities/class-fs-entity.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
<?php
    
/**
     * @package     Freemius
     * @copyright   Copyright (c) 2015, Freemius, Inc.
     * @license     https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
     * @since       1.0.3
     */

    
if ( ! defined'ABSPATH' ) ) {
        exit;
    }

    
/**
     * Get object's public variables.
     *
     * @author Vova Feldman (@svovaf)
     * @since  1.0.0
     *
     * @param object $object
     *
     * @return array
     */
    
function fs_get_object_public_vars$object ) {
        return 
get_object_vars$object );
    }

    class 
FS_Entity {
        
/**
         * @var number
         */
        
public $id;
        
/**
         * @var string Datetime value in 'YYYY-MM-DD HH:MM:SS' format.
         */
        
public $updated;
        
/**
         * @var string Datetime value in 'YYYY-MM-DD HH:MM:SS' format.
         */
        
public $created;

        
/**
         * @param bool|object $entity
         */
        
function __construct$entity false ) {
            if ( ! ( 
$entity instanceof stdClass ) && ! ( $entity instanceof FS_Entity ) ) {
                return;
            }

            
$props fs_get_object_public_vars$this );

            foreach ( 
$props as $key => $def_value ) {
                
$this->{$key} = isset( $entity->{$key} ) ?
                    
$entity->{$key} :
                    
$def_value;
            }
        }

        static function 
get_type() {
            return 
'type';
        }

        
/**
         * @author Vova Feldman (@svovaf)
         * @since  1.0.6
         *
         * @param FS_Entity $entity1
         * @param FS_Entity $entity2
         *
         * @return bool
         */
        
static function equals$entity1$entity2 ) {
            if ( 
is_null$entity1 ) && is_null$entity2 ) ) {
                return 
true;
            } else if ( 
is_object$entity1 ) && is_object$entity2 ) ) {
                return ( 
$entity1->id == $entity2->id );
            } else if ( 
is_object$entity1 ) ) {
                return 
is_null$entity1->id );
            } else {
                return 
is_null$entity2->id );
            }
        }

        private 
$_is_updated false;

        
/**
         * Update object property.
         *
         * @author Vova Feldman (@svovaf)
         * @since  1.0.9
         *
         * @param  string|array[string]mixed $key
         * @param string|bool $val
         *
         * @return bool
         */
        
function update$key$val false ) {
            if ( ! 
is_array$key ) ) {
                
$key = array( $key => $val );
            }

            
$is_updated false;

            foreach ( 
$key as $k => $v ) {
                if ( 
$this->{$k} === $v ) {
                    continue;
                }

                if ( ( 
is_string$this->{$k} ) && is_numeric$v ) ||
                       ( 
is_numeric$this->{$k} ) && is_string$v ) ) ) &&
                     
$this->{$k} == $v
                
) {
                    continue;
                }

                
// Update value.
                
$this->{$k} = $v;

                
$is_updated true;
            }

            
$this->_is_updated $is_updated;

            return 
$is_updated;
        }

        
/**
         * Checks if entity was updated.
         *
         * @author Vova Feldman (@svovaf)
         * @since  1.0.9
         *
         * @return bool
         */
        
function is_updated() {
            return 
$this->_is_updated;
        }

        
/**
         * @param $id
         *
         * @author Vova Feldman (@svovaf)
         * @since  1.1.2
         *
         * @return bool
         */
        
static function is_valid_id($id){
            return 
is_numeric($id);
        }
    }