From 00e59a62a0cd5f01a85a768299ce9355b756b276 Mon Sep 17 00:00:00 2001 From: GitHub Date: Tue, 28 Nov 2023 10:42:40 +0000 Subject: [PATCH] [devices-module] Use cache service (#193) --- src/API/ConnectionManager.php | 1 - src/Clients/Television.php | 7 ------- src/Connector/Connector.php | 8 -------- src/Helpers/Device.php | 13 ------------- src/Queue/Consumers/StoreChannelPropertyState.php | 5 ----- src/Queue/Consumers/StoreDeviceConnectionState.php | 7 ------- src/Queue/Consumers/WriteChannelPropertyState.php | 6 ------ src/Writers/Event.php | 9 --------- src/Writers/Exchange.php | 7 ------- src/Writers/Periodic.php | 7 ------- tests/common.neon | 2 ++ 11 files changed, 2 insertions(+), 70 deletions(-) diff --git a/src/API/ConnectionManager.php b/src/API/ConnectionManager.php index 51a7d7f..02d5b48 100644 --- a/src/API/ConnectionManager.php +++ b/src/API/ConnectionManager.php @@ -52,7 +52,6 @@ public function __construct( * @throws DevicesExceptions\InvalidState * @throws MetadataExceptions\InvalidArgument * @throws MetadataExceptions\InvalidState - * @throws MetadataExceptions\MalformedInput */ public function getConnection(MetadataDocuments\DevicesModule\Device $device): TelevisionApi { diff --git a/src/Clients/Television.php b/src/Clients/Television.php index 82c5e21..f79d3b1 100644 --- a/src/Clients/Television.php +++ b/src/Clients/Television.php @@ -76,11 +76,6 @@ final class Television implements Client private EventLoop\TimerInterface|null $handlerTimer = null; - /** - * @param DevicesModels\Configuration\Devices\Repository $devicesConfigurationRepository - * @param DevicesModels\Configuration\Channels\Repository $channelsConfigurationRepository - * @param DevicesModels\Configuration\Channels\Properties\Repository $channelsPropertiesConfigurationRepository - */ public function __construct( private readonly MetadataDocuments\DevicesModule\Connector $connector, private readonly API\ConnectionManager $connectionManager, @@ -103,7 +98,6 @@ public function __construct( * @throws Exceptions\Runtime * @throws MetadataExceptions\InvalidArgument * @throws MetadataExceptions\InvalidState - * @throws MetadataExceptions\MalformedInput */ public function connect(): void { @@ -539,7 +533,6 @@ private function processDevice(MetadataDocuments\DevicesModule\Device $device): * @throws DevicesExceptions\InvalidState * @throws MetadataExceptions\InvalidArgument * @throws MetadataExceptions\InvalidState - * @throws MetadataExceptions\MalformedInput */ private function createDeviceClient(MetadataDocuments\DevicesModule\Device $device): void { diff --git a/src/Connector/Connector.php b/src/Connector/Connector.php index 4dc8be0..b484889 100644 --- a/src/Connector/Connector.php +++ b/src/Connector/Connector.php @@ -20,8 +20,6 @@ use FastyBird\Connector\Viera\Entities; use FastyBird\Connector\Viera\Queue; use FastyBird\Connector\Viera\Writers; -use FastyBird\Library\Metadata\Documents as MetadataDocuments; -use FastyBird\Library\Metadata\Exceptions as MetadataExceptions; use FastyBird\Library\Metadata\Types as MetadataTypes; use FastyBird\Module\Devices\Connectors as DevicesConnectors; use FastyBird\Module\Devices\Entities as DevicesEntities; @@ -56,9 +54,6 @@ final class Connector implements DevicesConnectors\Connector private EventLoop\TimerInterface|null $consumersTimer = null; - /** - * @param DevicesModels\Configuration\Connectors\Repository $connectorsConfigurationRepository - */ public function __construct( private readonly DevicesEntities\Connectors\Connector $connector, private readonly Clients\ClientFactory $clientFactory, @@ -76,9 +71,6 @@ public function __construct( /** * @throws DevicesExceptions\InvalidState - * @throws MetadataExceptions\InvalidArgument - * @throws MetadataExceptions\InvalidState - * @throws MetadataExceptions\MalformedInput */ public function execute(): void { diff --git a/src/Helpers/Device.php b/src/Helpers/Device.php index b215af0..d1e8725 100644 --- a/src/Helpers/Device.php +++ b/src/Helpers/Device.php @@ -40,9 +40,6 @@ final class Device { - /** - * @param DevicesModels\Configuration\Devices\Properties\Repository $devicesPropertiesConfigurationRepository - */ public function __construct( private readonly DevicesModels\Configuration\Devices\Properties\Repository $devicesPropertiesConfigurationRepository, ) @@ -53,7 +50,6 @@ public function __construct( * @throws DevicesExceptions\InvalidState * @throws MetadataExceptions\InvalidArgument * @throws MetadataExceptions\InvalidState - * @throws MetadataExceptions\MalformedInput */ public function getIpAddress(MetadataDocuments\DevicesModule\Device $device): string|null { @@ -80,7 +76,6 @@ public function getIpAddress(MetadataDocuments\DevicesModule\Device $device): st * @throws DevicesExceptions\InvalidState * @throws MetadataExceptions\InvalidArgument * @throws MetadataExceptions\InvalidState - * @throws MetadataExceptions\MalformedInput */ public function getPort(MetadataDocuments\DevicesModule\Device $device): int { @@ -107,7 +102,6 @@ public function getPort(MetadataDocuments\DevicesModule\Device $device): int * @throws DevicesExceptions\InvalidState * @throws MetadataExceptions\InvalidArgument * @throws MetadataExceptions\InvalidState - * @throws MetadataExceptions\MalformedInput */ public function isEncrypted(MetadataDocuments\DevicesModule\Device $device): bool { @@ -134,7 +128,6 @@ public function isEncrypted(MetadataDocuments\DevicesModule\Device $device): boo * @throws DevicesExceptions\InvalidState * @throws MetadataExceptions\InvalidArgument * @throws MetadataExceptions\InvalidState - * @throws MetadataExceptions\MalformedInput */ public function getAppId(MetadataDocuments\DevicesModule\Device $device): string|null { @@ -161,7 +154,6 @@ public function getAppId(MetadataDocuments\DevicesModule\Device $device): string * @throws DevicesExceptions\InvalidState * @throws MetadataExceptions\InvalidArgument * @throws MetadataExceptions\InvalidState - * @throws MetadataExceptions\MalformedInput */ public function getEncryptionKey(MetadataDocuments\DevicesModule\Device $device): string|null { @@ -188,7 +180,6 @@ public function getEncryptionKey(MetadataDocuments\DevicesModule\Device $device) * @throws DevicesExceptions\InvalidState * @throws MetadataExceptions\InvalidArgument * @throws MetadataExceptions\InvalidState - * @throws MetadataExceptions\MalformedInput */ public function getModel(MetadataDocuments\DevicesModule\Device $device): string|null { @@ -215,7 +206,6 @@ public function getModel(MetadataDocuments\DevicesModule\Device $device): string * @throws DevicesExceptions\InvalidState * @throws MetadataExceptions\InvalidArgument * @throws MetadataExceptions\InvalidState - * @throws MetadataExceptions\MalformedInput */ public function getManufacturer(MetadataDocuments\DevicesModule\Device $device): string|null { @@ -242,7 +232,6 @@ public function getManufacturer(MetadataDocuments\DevicesModule\Device $device): * @throws DevicesExceptions\InvalidState * @throws MetadataExceptions\InvalidArgument * @throws MetadataExceptions\InvalidState - * @throws MetadataExceptions\MalformedInput */ public function getMacAddress(MetadataDocuments\DevicesModule\Device $device): string|null { @@ -269,7 +258,6 @@ public function getMacAddress(MetadataDocuments\DevicesModule\Device $device): s * @throws DevicesExceptions\InvalidState * @throws MetadataExceptions\InvalidArgument * @throws MetadataExceptions\InvalidState - * @throws MetadataExceptions\MalformedInput */ public function getSerialNumber(MetadataDocuments\DevicesModule\Device $device): string|null { @@ -296,7 +284,6 @@ public function getSerialNumber(MetadataDocuments\DevicesModule\Device $device): * @throws DevicesExceptions\InvalidState * @throws MetadataExceptions\InvalidArgument * @throws MetadataExceptions\InvalidState - * @throws MetadataExceptions\MalformedInput */ public function getStateReadingDelay(MetadataDocuments\DevicesModule\Device $device): float { diff --git a/src/Queue/Consumers/StoreChannelPropertyState.php b/src/Queue/Consumers/StoreChannelPropertyState.php index de57ebe..4aa35c1 100644 --- a/src/Queue/Consumers/StoreChannelPropertyState.php +++ b/src/Queue/Consumers/StoreChannelPropertyState.php @@ -44,11 +44,6 @@ final class StoreChannelPropertyState implements Queue\Consumer use Nette\SmartObject; - /** - * @param DevicesModels\Configuration\Devices\Repository $devicesConfigurationRepository - * @param DevicesModels\Configuration\Channels\Repository $channelsConfigurationRepository - * @param DevicesModels\Configuration\Channels\Properties\Repository $channelsPropertiesConfigurationRepository - */ public function __construct( private readonly Viera\Logger $logger, private readonly DevicesModels\Configuration\Devices\Repository $devicesConfigurationRepository, diff --git a/src/Queue/Consumers/StoreDeviceConnectionState.php b/src/Queue/Consumers/StoreDeviceConnectionState.php index 7e6608a..7c45f4a 100644 --- a/src/Queue/Consumers/StoreDeviceConnectionState.php +++ b/src/Queue/Consumers/StoreDeviceConnectionState.php @@ -20,7 +20,6 @@ use FastyBird\Connector\Viera\Entities; use FastyBird\Connector\Viera\Queue; use FastyBird\Library\Metadata; -use FastyBird\Library\Metadata\Documents as MetadataDocuments; use FastyBird\Library\Metadata\Exceptions as MetadataExceptions; use FastyBird\Library\Metadata\Types as MetadataTypes; use FastyBird\Module\Devices\Exceptions as DevicesExceptions; @@ -42,12 +41,6 @@ final class StoreDeviceConnectionState implements Queue\Consumer use Nette\SmartObject; - /** - * @param DevicesModels\Configuration\Devices\Repository $devicesConfigurationRepository - * @param DevicesModels\Configuration\Devices\Properties\Repository $devicesPropertiesConfigurationRepository - * @param DevicesModels\Configuration\Channels\Repository $channelsConfigurationRepository - * @param DevicesModels\Configuration\Channels\Properties\Repository $channelsPropertiesConfigurationRepository - */ public function __construct( private readonly Viera\Logger $logger, private readonly DevicesModels\Configuration\Devices\Repository $devicesConfigurationRepository, diff --git a/src/Queue/Consumers/WriteChannelPropertyState.php b/src/Queue/Consumers/WriteChannelPropertyState.php index c912c2b..6c23809 100644 --- a/src/Queue/Consumers/WriteChannelPropertyState.php +++ b/src/Queue/Consumers/WriteChannelPropertyState.php @@ -55,12 +55,6 @@ final class WriteChannelPropertyState implements Queue\Consumer use Nette\SmartObject; - /** - * @param DevicesModels\Configuration\Connectors\Repository $connectorsConfigurationRepository - * @param DevicesModels\Configuration\Devices\Repository $devicesConfigurationRepository - * @param DevicesModels\Configuration\Channels\Repository $channelsConfigurationRepository - * @param DevicesModels\Configuration\Channels\Properties\Repository $channelsPropertiesConfigurationRepository - */ public function __construct( private readonly Queue\Queue $queue, private readonly API\ConnectionManager $connectionManager, diff --git a/src/Writers/Event.php b/src/Writers/Event.php index b2754e6..7066071 100644 --- a/src/Writers/Event.php +++ b/src/Writers/Event.php @@ -21,7 +21,6 @@ use FastyBird\Connector\Viera\Queue; use FastyBird\DateTimeFactory; use FastyBird\Library\Metadata\Documents as MetadataDocuments; -use FastyBird\Library\Metadata\Exceptions as MetadataExceptions; use FastyBird\Module\Devices\Events as DevicesEvents; use FastyBird\Module\Devices\Exceptions as DevicesExceptions; use FastyBird\Module\Devices\Models as DevicesModels; @@ -43,11 +42,6 @@ class Event extends Periodic implements Writer, EventDispatcher\EventSubscriberI public const NAME = 'event'; - /** - * @param DevicesModels\Configuration\Devices\Repository $devicesConfigurationRepository - * @param DevicesModels\Configuration\Channels\Repository $channelsConfigurationRepository - * @param DevicesModels\Configuration\Channels\Properties\Repository $channelsPropertiesConfigurationRepository - */ public function __construct( MetadataDocuments\DevicesModule\Connector $connector, Helpers\Entity $entityHelper, @@ -84,9 +78,6 @@ public static function getSubscribedEvents(): array /** * @throws DevicesExceptions\InvalidState * @throws Exceptions\Runtime - * @throws MetadataExceptions\InvalidArgument - * @throws MetadataExceptions\InvalidState - * @throws MetadataExceptions\MalformedInput */ public function stateChanged( DevicesEvents\ChannelPropertyStateEntityCreated|DevicesEvents\ChannelPropertyStateEntityUpdated $event, diff --git a/src/Writers/Exchange.php b/src/Writers/Exchange.php index 28cded9..0ee12b1 100644 --- a/src/Writers/Exchange.php +++ b/src/Writers/Exchange.php @@ -45,10 +45,6 @@ class Exchange extends Periodic implements Writer, ExchangeConsumers\Consumer public const NAME = 'exchange'; /** - * @param DevicesModels\Configuration\Devices\Repository $devicesConfigurationRepository - * @param DevicesModels\Configuration\Channels\Repository $channelsConfigurationRepository - * @param DevicesModels\Configuration\Channels\Properties\Repository $channelsPropertiesConfigurationRepository - * * @throws ExchangeExceptions\InvalidArgument */ public function __construct( @@ -82,8 +78,6 @@ public function __construct( /** * @throws DevicesExceptions\InvalidState * @throws ExchangeExceptions\InvalidArgument - * @throws MetadataExceptions\InvalidArgument - * @throws MetadataExceptions\InvalidState */ public function connect(): void { @@ -107,7 +101,6 @@ public function disconnect(): void * @throws Exceptions\Runtime * @throws MetadataExceptions\InvalidArgument * @throws MetadataExceptions\InvalidState - * @throws MetadataExceptions\MalformedInput */ public function consume( MetadataTypes\ModuleSource|MetadataTypes\PluginSource|MetadataTypes\ConnectorSource|MetadataTypes\AutomatorSource $source, diff --git a/src/Writers/Periodic.php b/src/Writers/Periodic.php index e0aae5f..cbfc632 100644 --- a/src/Writers/Periodic.php +++ b/src/Writers/Periodic.php @@ -67,11 +67,6 @@ abstract class Periodic implements Writer private EventLoop\TimerInterface|null $handlerTimer = null; - /** - * @param DevicesModels\Configuration\Devices\Repository $devicesConfigurationRepository - * @param DevicesModels\Configuration\Channels\Repository $channelsConfigurationRepository - * @param DevicesModels\Configuration\Channels\Properties\Repository $channelsPropertiesConfigurationRepository - */ public function __construct( protected readonly MetadataDocuments\DevicesModule\Connector $connector, protected readonly Helpers\Entity $entityHelper, @@ -88,8 +83,6 @@ public function __construct( /** * @throws DevicesExceptions\InvalidState - * @throws MetadataExceptions\InvalidArgument - * @throws MetadataExceptions\InvalidState */ public function connect(): void { diff --git a/tests/common.neon b/tests/common.neon index ef04e51..4e51781 100644 --- a/tests/common.neon +++ b/tests/common.neon @@ -45,6 +45,8 @@ services: type: React\EventLoop\LoopInterface } + cache.storage: Nette\Caching\Storages\MemoryStorage + contributteTranslation: locales: default: en_US