| Linux webm007.cluster106.gra.hosting.ovh.net 5.15.167-ovh-vps-grsec-zfs-classid #1 SMP Tue Sep 17 08:14:20 UTC 2024 x86_64 Path : /home/eglisebaa/www/wp-content/plugins/elementor/modules/atomic-widgets/utils/ |
| Current File : /home/eglisebaa/www/wp-content/plugins/elementor/modules/atomic-widgets/utils/memo.php |
<?php
namespace Elementor\Modules\AtomicWidgets\Utils;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
class Memo {
private array $cache = [];
public function memoize( string $key, callable $callback ) {
return function() use ( $key, $callback ) {
if ( array_key_exists( $key, $this->cache ) ) {
return $this->cache[ $key ];
}
$this->cache[ $key ] = call_user_func( $callback );
return $this->cache[ $key ];
};
}
}