HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux WebLive 5.15.0-79-generic #86-Ubuntu SMP Mon Jul 10 16:07:21 UTC 2023 x86_64
User: ubuntu (1000)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/html/wptoho/wp-content/plugins/defender-security/framework/helper/class-array-cache.php
<?php
/**
 * Array cache helper.
 *
 * @package Calotes\Helper
 */

namespace Calotes\Helper;

use Calotes\Base\Component;

/**
 * This is runtime cache, so the cache content will be flush after each refresh.
 */
class Array_Cache extends Component {

	/**
	 * The cached array.
	 *
	 * @var array
	 */
	protected static $cached = array();

	/**
	 * Sets a value in the cache.
	 *
	 * @param  mixed $name  The name of the value to set.
	 * @param  mixed $value  The value to set.
	 * @param  mixed $group  The group of the value (optional).
	 *
	 * @return void
	 */
	public static function set( $name, $value, $group = null ) {
		$key                  = $name . $group;
		self::$cached[ $key ] = $value;
	}

	/**
	 * Retrieves a value from the cache.
	 *
	 * @param  mixed $name  The name of the value to retrieve.
	 * @param  mixed $group  The group of the value (optional).
	 * @param  mixed $default_name  The default value to return if the value is not found (optional).
	 *
	 * @return mixed The retrieved value or the default value if not found.
	 */
	public static function get( $name, $group = null, $default_name = null ) {
		$key = $name . $group;

		return self::$cached[ $key ] ?? $default_name;
	}

	/**
	 * Appends a new element to a cached array.
	 *
	 * @param  mixed $name  The name of the value to append.
	 * @param  mixed $value  The value to append.
	 * @param  mixed $group  The group of the value (optional).
	 *
	 * @return void
	 */
	public static function append( $name, $value, $group = null ) {
		$data = self::get( $name, $group, array() );
		if ( is_array( $data ) ) {
			$data[] = $value;
		}
		self::set( $name, $data, $group );
	}

	/**
	 * Removes a value from the cache.
	 *
	 * @param  mixed $name  The name of the value to remove.
	 * @param  mixed $group  The group of the value (optional).
	 *
	 * @return bool True if the value was successfully removed, false otherwise.
	 */
	public static function remove( $name, $group = null ) {
		$key = $name . $group;
		if ( isset( self::$cached[ $key ] ) ) {
			unset( self::$cached[ $key ] );

			return true;
		}

		return false;
	}
}