PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 2.19.6
GiveWP – Donation Plugin and Fundraising Platform v2.19.6
4.16.8 4.16.7.2 4.16.7.1 4.16.7 4.16.6.1 4.16.6 4.16.5.1 4.16.5 4.16.4 4.16.3 4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 2.3.2 2.30.0 2.31.0 2.31.1 All 253 releases
give / src / Onboarding / SettingsRepository.php

SettingsRepository.php in GiveWP – Donation Plugin and Fundraising Platform 2.19.6, at src/Onboarding/SettingsRepository.php

85 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Give\Onboarding;
4
5 /**
6 * @since 2.8.0
7 */
8 class SettingsRepository
9 {
10
11 /** @var array */
12 protected $settings;
13
14 /** @var callable */
15 protected $persistCallback;
16
17 /**
18 * @since 2.8.0
19 *
20 * @param callable $persistCallback
21 *
22 * @param array $settings
23 */
24 public function __construct(array $settings, callable $persistCallback)
25 {
26 $this->settings = $settings;
27 $this->persistCallback = $persistCallback;
28 }
29
30 /**
31 * @since 2.8.0
32 *
33 * @param string $name The setting name.
34 *
35 * @return mixed The setting value.
36 *
37 */
38 public function get($name)
39 {
40 return ($this->has($name))
41 ? $this->settings[$name]
42 : null;
43 }
44
45 /**
46 * @since 2.8.0
47 *
48 * @param mixed $value The setting value.
49 *
50 * @param string $name The setting name.
51 *
52 * @return void
53 *
54 */
55 public function set($name, $value)
56 {
57 $this->settings[$name] = $value;
58 }
59
60 /**
61 * @since 2.8.0
62 *
63 * @param string $name The setting name.
64 *
65 * @return bool
66 *
67 */
68 public function has($name)
69 {
70 return isset($this->settings[$name]);
71 }
72
73 /**
74 * @since 2.8.0
75 * @return bool False if value was not updated and true if value was updated.
76 *
77 */
78 public function save()
79 {
80 return $this->persistCallback->__invoke(
81 $this->settings
82 );
83 }
84 }
85