PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 2.13.1
GiveWP – Donation Plugin and Fundraising Platform v2.13.1
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
74 lines 1.2 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 /** @var array */
11 protected $settings;
12
13 /** @var callable */
14 protected $persistCallback;
15
16 /**
17 * @param array $settings
18 * @param callable $persistCallback
19 *
20 * @since 2.8.0
21 */
22 public function __construct( array $settings, callable $persistCallback ) {
23 $this->settings = $settings;
24 $this->persistCallback = $persistCallback;
25 }
26
27 /**
28 * @param string $name The setting name.
29 *
30 * @return mixed The setting value.
31 *
32 * @since 2.8.0
33 */
34 public function get( $name ) {
35 return ( $this->has( $name ) )
36 ? $this->settings[ $name ]
37 : null;
38 }
39
40 /**
41 * @param string $name The setting name.
42 * @param mixed $value The setting value.
43 *
44 * @return void
45 *
46 * @since 2.8.0
47 */
48 public function set( $name, $value ) {
49 $this->settings[ $name ] = $value;
50 }
51
52 /**
53 * @param string $name The setting name.
54 *
55 * @return bool
56 *
57 * @since 2.8.0
58 */
59 public function has( $name ) {
60 return isset( $this->settings[ $name ] );
61 }
62
63 /**
64 * @return bool False if value was not updated and true if value was updated.
65 *
66 * @since 2.8.0
67 */
68 public function save() {
69 return $this->persistCallback->__invoke(
70 $this->settings
71 );
72 }
73 }
74