From: Philipp Date: Thu, 29 Dec 2022 21:37:12 +0000 (+0100) Subject: Rename Interface X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=86f80af432e0399494384152a3708c411d00a125;p=friendica.git Rename Interface --- diff --git a/src/Console/PostUpdate.php b/src/Console/PostUpdate.php index cf15fe3e39..702b127109 100644 --- a/src/Console/PostUpdate.php +++ b/src/Console/PostUpdate.php @@ -22,7 +22,7 @@ namespace Friendica\Console; use Friendica\App; -use Friendica\Core\KeyValueStorage\Capabilities\ICanManageKeyValuePairs; +use Friendica\Core\KeyValueStorage\Capabilities\IManageKeyValuePairs; use Friendica\Core\L10n; use Friendica\Core\Update; @@ -38,7 +38,7 @@ class PostUpdate extends \Asika\SimpleConsole\Console */ private $appMode; /** - * @var ICanManageKeyValuePairs + * @var IManageKeyValuePairs */ private $keyValue; /** @@ -60,7 +60,7 @@ HELP; return $help; } - public function __construct(App\Mode $appMode, ICanManageKeyValuePairs $keyValue, L10n $l10n, array $argv = null) + public function __construct(App\Mode $appMode, IManageKeyValuePairs $keyValue, L10n $l10n, array $argv = null) { parent::__construct($argv); diff --git a/src/Core/KeyValueStorage/Capabilities/ICanManageKeyValuePairs.php b/src/Core/KeyValueStorage/Capabilities/ICanManageKeyValuePairs.php deleted file mode 100644 index 11c8b772b3..0000000000 --- a/src/Core/KeyValueStorage/Capabilities/ICanManageKeyValuePairs.php +++ /dev/null @@ -1,64 +0,0 @@ -. - * - */ - -namespace Friendica\Core\KeyValueStorage\Capabilities; - -use Friendica\Core\KeyValueStorage\Exceptions\KeyValueStoragePersistenceException; - -/** - * Interface for Friendica specific Key-Value pair storage - */ -interface ICanManageKeyValuePairs extends \ArrayAccess -{ - /** - * Get a particular value from the KeyValue Storage - * - * @param string $key The key to query - * - * @return mixed Stored value or null if it does not exist - * - * @throws KeyValueStoragePersistenceException In case the persistence layer throws errors - * - */ - public function get(string $key); - - /** - * Sets a value for a given key - * - * Note: Please do not store booleans - convert to 0/1 integer values! - * - * @param string $key The configuration key to set - * @param mixed $value The value to store - * - * @throws KeyValueStoragePersistenceException In case the persistence layer throws errors - */ - public function set(string $key, $value): void; - - /** - * Deletes the given key. - * - * @param string $key The configuration key to delete - * - * @throws KeyValueStoragePersistenceException In case the persistence layer throws errors - * - */ - public function delete(string $key): void; -} diff --git a/src/Core/KeyValueStorage/Capabilities/IManageKeyValuePairs.php b/src/Core/KeyValueStorage/Capabilities/IManageKeyValuePairs.php new file mode 100644 index 0000000000..64b317bf1a --- /dev/null +++ b/src/Core/KeyValueStorage/Capabilities/IManageKeyValuePairs.php @@ -0,0 +1,64 @@ +. + * + */ + +namespace Friendica\Core\KeyValueStorage\Capabilities; + +use Friendica\Core\KeyValueStorage\Exceptions\KeyValueStoragePersistenceException; + +/** + * Interface for Friendica specific Key-Value pair storage + */ +interface IManageKeyValuePairs extends \ArrayAccess +{ + /** + * Get a particular value from the KeyValue Storage + * + * @param string $key The key to query + * + * @return mixed Stored value or null if it does not exist + * + * @throws KeyValueStoragePersistenceException In case the persistence layer throws errors + * + */ + public function get(string $key); + + /** + * Sets a value for a given key + * + * Note: Please do not store booleans - convert to 0/1 integer values! + * + * @param string $key The configuration key to set + * @param mixed $value The value to store + * + * @throws KeyValueStoragePersistenceException In case the persistence layer throws errors + */ + public function set(string $key, $value): void; + + /** + * Deletes the given key. + * + * @param string $key The configuration key to delete + * + * @throws KeyValueStoragePersistenceException In case the persistence layer throws errors + * + */ + public function delete(string $key): void; +} diff --git a/src/Core/KeyValueStorage/Type/AbstractKeyValueStorage.php b/src/Core/KeyValueStorage/Type/AbstractKeyValueStorage.php index cfcebb6ffd..169d27f69b 100644 --- a/src/Core/KeyValueStorage/Type/AbstractKeyValueStorage.php +++ b/src/Core/KeyValueStorage/Type/AbstractKeyValueStorage.php @@ -21,12 +21,12 @@ namespace Friendica\Core\KeyValueStorage\Type; -use Friendica\Core\KeyValueStorage\Capabilities\ICanManageKeyValuePairs; +use Friendica\Core\KeyValueStorage\Capabilities\IManageKeyValuePairs; /** * An abstract helper class for Key-Value storage classes */ -abstract class AbstractKeyValueStorage implements ICanManageKeyValuePairs +abstract class AbstractKeyValueStorage implements IManageKeyValuePairs { /** {@inheritDoc} */ public function get(string $key) diff --git a/src/DI.php b/src/DI.php index a430b0daa2..ecdf92530c 100644 --- a/src/DI.php +++ b/src/DI.php @@ -181,9 +181,9 @@ abstract class DI return self::$dice->create(Core\Config\Capability\IManageConfigValues::class); } - public static function keyValue(): Core\KeyValueStorage\Capabilities\ICanManageKeyValuePairs + public static function keyValue(): Core\KeyValueStorage\Capabilities\IManageKeyValuePairs { - return self::$dice->create(Core\KeyValueStorage\Capabilities\ICanManageKeyValuePairs::class); + return self::$dice->create(Core\KeyValueStorage\Capabilities\IManageKeyValuePairs::class); } /** diff --git a/static/dependencies.config.php b/static/dependencies.config.php index 645ab968eb..116874445b 100644 --- a/static/dependencies.config.php +++ b/static/dependencies.config.php @@ -245,7 +245,7 @@ return [ ['getBackend', [], Dice::CHAIN_CALL], ], ], - \Friendica\Core\KeyValueStorage\Capabilities\ICanManageKeyValuePairs::class => [ + \Friendica\Core\KeyValueStorage\Capabilities\IManageKeyValuePairs::class => [ 'instanceOf' => \Friendica\Core\KeyValueStorage\Type\DBKeyValueStorage::class, ], Network\HTTPClient\Capability\ICanSendHttpRequests::class => [ diff --git a/tests/src/Core/KeyValueStorage/DBKeyValueStorageTest.php b/tests/src/Core/KeyValueStorage/DBKeyValueStorageTest.php index 967da78a46..1492c3de51 100644 --- a/tests/src/Core/KeyValueStorage/DBKeyValueStorageTest.php +++ b/tests/src/Core/KeyValueStorage/DBKeyValueStorageTest.php @@ -22,7 +22,7 @@ namespace Friendica\Test\src\Core\KeyValueStorage; use Friendica\Core\Config\ValueObject\Cache; -use Friendica\Core\KeyValueStorage\Capabilities\ICanManageKeyValuePairs; +use Friendica\Core\KeyValueStorage\Capabilities\IManageKeyValuePairs; use Friendica\Core\KeyValueStorage\Type\DBKeyValueStorage; use Friendica\Database\Database; use Friendica\Database\Definition\DbaDefinition; @@ -53,7 +53,7 @@ class DBKeyValueStorageTest extends KeyValueStorageTest $this->tearDownDb(); } - public function getInstance(): ICanManageKeyValuePairs + public function getInstance(): IManageKeyValuePairs { $cache = new Cache(); $cache->set('database', 'disable_pdo', true); diff --git a/tests/src/Core/KeyValueStorage/KeyValueStorageTest.php b/tests/src/Core/KeyValueStorage/KeyValueStorageTest.php index 6c393310d5..b3aee20f59 100644 --- a/tests/src/Core/KeyValueStorage/KeyValueStorageTest.php +++ b/tests/src/Core/KeyValueStorage/KeyValueStorageTest.php @@ -21,18 +21,18 @@ namespace Friendica\Test\src\Core\KeyValueStorage; -use Friendica\Core\KeyValueStorage\Capabilities\ICanManageKeyValuePairs; +use Friendica\Core\KeyValueStorage\Capabilities\IManageKeyValuePairs; use Friendica\Test\MockedTest; abstract class KeyValueStorageTest extends MockedTest { - abstract public function getInstance(): ICanManageKeyValuePairs; + abstract public function getInstance(): IManageKeyValuePairs; public function testInstance() { $instance = $this->getInstance(); - self::assertInstanceOf(ICanManageKeyValuePairs::class, $instance); + self::assertInstanceOf(IManageKeyValuePairs::class, $instance); } public function dataTests(): array