Server : Apache System : Linux pod-100823:apache2_74:v0.5.7 5.4.0-1138-gcp #147~18.04.1-Ubuntu SMP Mon Oct 7 21:46:26 UTC 2024 x86_64 User : www-data ( 33) PHP Version : 7.4.33.7 Disable Function : apache_child_terminate,apache_get_modules,apache_get_version,apache_getenv,apache_note,apache_setenv,disk_free_space,disk_total_space,diskfreespace,dl,exec,fastcgi_finish_request,link,opcache_compile_file,opcache_get_configuration,opcache_invalidate,opcache_is_script_cached,opcache_reset,passthru,pclose,pcntl_exec,popen,posix_getpid,posix_getppid,posix_getpwuid,posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid,posix_setpgid,posix_setsid,posix_setuid,posix_uname,proc_close,proc_get_status,proc_nice,proc_open,proc_terminate,realpath_cache_get,shell_exec,show_source,symlink,system Directory : /nas/content/live/attorneyexperi/wp-content/plugins/wp-rocket/inc/classes/traits/ |
<?php namespace WP_Rocket\Traits; /** * Statically store values. * * @since 3.3 */ trait Memoize { /** * Store the values. * * @var array * @since 3.3 */ private static $memoized = []; /** * Tell if a value is memoized. * * @since 3.3 * * @param string $method Name of the method. * @param array $args Arguments passed to the parent method. It is used to build a hash. * @return bool */ final public static function is_memoized( $method, $args = [] ) { $hash = self::get_memoize_args_hash( $args ); return isset( self::$memoized[ $method ][ $hash ] ); } /** * Get a stored value. * * @since 3.3 * * @param string $method Name of the method. * @param array $args Arguments passed to the parent method. It is used to build a hash. * @return mixed */ final public static function get_memoized( $method, $args = [] ) { $hash = self::get_memoize_args_hash( $args ); return isset( self::$memoized[ $method ][ $hash ] ) ? self::$memoized[ $method ][ $hash ] : null; } /** * Cache a value. * * @since 3.3 * * @param string $method Name of the method. * @param array $args Arguments passed to the parent method. It is used to build a hash. * @param mixed $value Value to store. * @return mixed The stored value. */ final public static function memoize( $method, $args = [], $value = null ) { $hash = self::get_memoize_args_hash( $args ); if ( ! isset( self::$memoized[ $method ] ) ) { self::$memoized[ $method ] = []; } self::$memoized[ $method ][ $hash ] = $value; return self::$memoized[ $method ][ $hash ]; //phpcs:ignore Universal.CodeAnalysis.ConstructorDestructorReturn.ReturnValueFound } /** * Create a hash based on an array of arguments. * * @since 3.3 * * @param array $args An array of arguments. * @return string */ private static function get_memoize_args_hash( $args ) { if ( [] === $args ) { return 'd751713988987e9331980363e24189ce'; // `md5( json_encode( [] ) )` } return md5( call_user_func( 'json_encode', $args ) ); } }