: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
* @copyright Copyright (c) 2015, Freemius, Inc.
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
if ( ! defined( 'ABSPATH' ) ) {
* Get object's public variables.
* @author Vova Feldman (@svovaf)
function fs_get_object_public_vars( $object ) {
return get_object_vars( $object );
* @var string Datetime value in 'YYYY-MM-DD HH:MM:SS' format.
* @var string Datetime value in 'YYYY-MM-DD HH:MM:SS' format.
* @param bool|object $entity
function __construct( $entity = false ) {
if ( ! ( $entity instanceof stdClass ) && ! ( $entity instanceof FS_Entity ) ) {
$props = fs_get_object_public_vars( $this );
foreach ( $props as $key => $def_value ) {
$this->{$key} = isset( $entity->{$key} ) ?
static function get_type() {
* @author Vova Feldman (@svovaf)
* @param FS_Entity $entity1
* @param FS_Entity $entity2
static function equals( $entity1, $entity2 ) {
if ( is_null( $entity1 ) && is_null( $entity2 ) ) {
} else if ( is_object( $entity1 ) && is_object( $entity2 ) ) {
return ( $entity1->id == $entity2->id );
} else if ( is_object( $entity1 ) ) {
return is_null( $entity1->id );
return is_null( $entity2->id );
private $_is_updated = false;
* Update object property.
* @author Vova Feldman (@svovaf)
* @param string|array[string]mixed $key
* @param string|bool $val
function update( $key, $val = false ) {
if ( ! is_array( $key ) ) {
$key = array( $key => $val );
foreach ( $key as $k => $v ) {
if ( $this->{$k} === $v ) {
if ( ( is_string( $this->{$k} ) && is_numeric( $v ) ||
( is_numeric( $this->{$k} ) && is_string( $v ) ) ) &&
$this->_is_updated = $is_updated;
* Checks if entity was updated.
* @author Vova Feldman (@svovaf)
return $this->_is_updated;
* @author Vova Feldman (@svovaf)
static function is_valid_id($id){
* @author Leo Fajardo (@leorw)
public static function get_class_name() {
return get_called_class();