Diff: STRATO-apps/wordpress_03/app/wp-content/plugins/elementor/modules/atomic-widgets/utils/memo.php
Keine Baseline-Datei – Diff nur gegen leer.
1
-
1
+
<?php
2
+
3
+
namespace Elementor\Modules\AtomicWidgets\Utils;
4
+
5
+
if ( ! defined( 'ABSPATH' ) ) {
6
+
exit; // Exit if accessed directly.
7
+
}
8
+
9
+
class Memo {
10
+
private array $cache = [];
11
+
12
+
public function memoize( string $key, callable $callback ) {
13
+
return function() use ( $key, $callback ) {
14
+
if ( array_key_exists( $key, $this->cache ) ) {
15
+
return $this->cache[ $key ];
16
+
}
17
+
18
+
$this->cache[ $key ] = call_user_func( $callback );
19
+
return $this->cache[ $key ];
20
+
};
21
+
}
22
+
}
23
+