File tree Expand file tree Collapse file tree 2 files changed +38
-1
lines changed
Expand file tree Collapse file tree 2 files changed +38
-1
lines changed Original file line number Diff line number Diff line change 77/**
88 * @method static void set(string $key, $value)
99 * @method static mixed get(string $key, $default = null)
10+ * @method static bool has(string $key)
1011 * @method static void forget(string $key)
1112 * @method static void clear()
13+ *
14+ * @see \Native\Laravel\Settings
1215 */
1316class Settings extends Facade
1417{
15- protected static function getFacadeAccessor ()
18+ protected static function getFacadeAccessor (): string
1619 {
1720 return \Native \Laravel \Settings::class;
1821 }
Original file line number Diff line number Diff line change @@ -8,28 +8,62 @@ class Settings
88{
99 public function __construct (protected Client $ client ) {}
1010
11+ /**
12+ * Set a value in the settings using the provided key.
13+ *
14+ * @param string $key
15+ * @param $value
16+ * @return void
17+ */
1118 public function set (string $ key , $ value ): void
1219 {
1320 $ this ->client ->post ('settings/ ' .$ key , [
1421 'value ' => $ value ,
1522 ]);
1623 }
1724
25+ /**
26+ * Retrieve a value from the settings using the provided key.
27+ *
28+ * @param string $key
29+ * @param mixed|null $default
30+ *
31+ * @return mixed
32+ */
1833 public function get (string $ key , $ default = null ): mixed
1934 {
2035 return $ this ->client ->get ('settings/ ' .$ key )->json ('value ' ) ?? $ default ;
2136 }
2237
38+ /**
39+ * Determine if a value exists in the settings for the provided key.
40+ *
41+ * @param string $key
42+ *
43+ * @return bool
44+ */
2345 public function has (string $ key ): bool
2446 {
2547 return $ this ->client ->get ('settings/ ' .$ key )->json ('value ' ) !== null ;
2648 }
2749
50+ /**
51+ * Remove a value from the settings using the provided key.
52+ *
53+ * @param string $key
54+ *
55+ * @return void
56+ */
2857 public function forget (string $ key ): void
2958 {
3059 $ this ->client ->delete ('settings/ ' .$ key );
3160 }
3261
62+ /**
63+ * Clear all settings by deleting them from the storage.
64+ *
65+ * @return void
66+ */
3367 public function clear (): void
3468 {
3569 $ this ->client ->delete ('settings/ ' );
You can’t perform that action at this time.
0 commit comments