mirror of
https://github.com/anikeen-com/id.git
synced 2026-11-06 23:58:35 +00:00
Add the shared preference keys and appearance values
This commit is contained in:
3 files changed
+54
No files matched your search
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace Anikeen\Id\Enums;
|
||||
|
||||
/**
|
||||
* The values of the shared preference SharedPreference::APPEARANCE.
|
||||
*/
|
||||
class Appearance
|
||||
{
|
||||
/** Follow the operating system. */
|
||||
const SYSTEM = 'system';
|
||||
const LIGHT = 'light';
|
||||
const DARK = 'dark';
|
||||
|
||||
/**
|
||||
* @return list<string>
|
||||
*/
|
||||
public static function all(): array
|
||||
{
|
||||
return [self::SYSTEM, self::LIGHT, self::DARK];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace Anikeen\Id\Enums;
|
||||
|
||||
/**
|
||||
* The keys of the `global` preferences namespace, shared by all apps. Anikeen ID accepts only
|
||||
* these keys there, each with its own values.
|
||||
*/
|
||||
class SharedPreference
|
||||
{
|
||||
/** The namespace of the shared preferences. */
|
||||
const NAMESPACE = 'global';
|
||||
|
||||
/** Light or dark mode: one of the Appearance constants. */
|
||||
const APPEARANCE = 'appearance';
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace Anikeen\Id\Tests;
|
||||
|
||||
use Anikeen\Id\Enums\Appearance;
|
||||
use Anikeen\Id\Enums\SharedPreference;
|
||||
|
||||
class SharedPreferenceTest extends TestCase
|
||||
{
|
||||
public function test_the_shared_keys_and_values_match_anikeen_id(): void
|
||||
{
|
||||
$this->assertSame('global', SharedPreference::NAMESPACE);
|
||||
$this->assertSame('appearance', SharedPreference::APPEARANCE);
|
||||
$this->assertSame(['system', 'light', 'dark'], Appearance::all());
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user