PluginProbe
Bubble Menu – Floating Button Menu with Sticky Navigation / 4.0
Bubble Menu – Floating Button Menu with Sticky Navigation v4.0
trunk 1.3 2.0 2.2 2.2.1 3.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.1 3.1.1 4.0 4.0.1 4.0.2 4.0.3 4.0.4 4.0.5 4.0.6 4.0.7 4.1 4.1.1
bubble-menu / classes / Publish / Singleton.php

Singleton.php in Bubble Menu – Floating Button Menu with Sticky Navigation 4.0, at classes/Publish/Singleton.php

41 lines 750 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace BubbleMenu\Publish;
4
5 defined( 'ABSPATH' ) || exit;
6
7 class Singleton {
8 private static $instance;
9 private array $value = [];
10
11 private function __construct() {}
12
13 public static function getInstance() {
14 if (null === static::$instance) {
15 static::$instance = new static();
16 }
17
18 return static::$instance;
19 }
20
21 public function setValue($key, $value) {
22 $this->value[$key] = $value;
23 }
24
25 public function getValue(): array {
26 return $this->value;
27 }
28
29 public function hasKey( $key ) : bool {
30 return array_key_exists( $key, $this->value );
31 }
32
33 public function getValueByKey($key) {
34 if($this->hasKey($key)) {
35 return $this->value[$key];
36 }
37
38 // Return null or throw an exception if the key does not exist
39 return null;
40 }
41 }