HEX
Server: Apache
System: Linux 3b2f6704f3ac 4.4.0-101-generic #124-Ubuntu SMP Fri Nov 10 18:29:59 UTC 2017 x86_64
User: (2182)
PHP: 7.4.33
Disabled: proc_open, passthru, escapeshellcmd, exec, shell_exec, system, ini_alter, dl, popen, php_check_syntax, show_source, highlight_file, symlink, link, openlog, apache_child_terminate
Upload Files
File: /home/defaultwebsite/public/wp-content/plugins/reviews-feed/class/Common/BusinessDataCache.php
<?php
/**
 * Class BusinessDataCache
 *
 * @since 1.0
 */
namespace SmashBalloon\Reviews\Common;

class BusinessDataCache {

	public const CACHE_KEY = 'sbr_business_cache';

	private $business_cache;

	public function __construct() {
		$raw_cache = get_option( self::CACHE_KEY, '{}' );

		$this->business_cache = json_decode( $raw_cache, true );
	}

	public function get_data( $provider, $business_id ) {
		if ( ! empty( $this->business_cache[ $provider ][ $business_id ] ) ) {
			return $this->business_cache[ $provider ][ $business_id ];
		}

		return array();
	}

	public function update_single_datum( $provider, $business_id, $data_key, $data_value ) {
		if ( empty( $this->business_cache[ $provider ][ $business_id ] ) ) {
			return false;
		}
		$this->business_cache[ $provider ][ $business_id ][ $data_key ] = $data_value;

		return update_option( self::CACHE_KEY, wp_json_encode( $this->business_cache ), false );
	}

	public function update_data( $provider, $business_id, $data ) {
		$this->business_cache[ $provider ][ $business_id ] = $data;

		return update_option( self::CACHE_KEY, wp_json_encode( $this->business_cache ), false );
	}

}