$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); } /** * @author Leo Fajardo (@leorw) * @since 2.3.1 * * @return string */ public static function get_class_name() { return get_called_class(); } }