Skip to content

Commit

Permalink
Added pseudo filter
Browse files Browse the repository at this point in the history
  • Loading branch information
akadlec committed Aug 3, 2022
1 parent 20bf332 commit 291bf0b
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 12 deletions.
10 changes: 7 additions & 3 deletions src/Models/DataStorage/ChannelPropertiesRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,17 @@ public function findByIdentifier(
*
* @throws MetadataExceptions\FileNotFoundException
*/
public function findAllByChannel(Uuid\UuidInterface $channel): array
{
public function findAllByChannel(
Uuid\UuidInterface $channel,
?string $type = null
): array {
$entities = [];

foreach ($this->rawData as $id => $entity) {
if (array_key_exists('channel', $entity) && $channel->toString() === $entity['channel']) {
$entities[] = $this->getEntity(Uuid\Uuid::fromString($id), $this->rawData[$id]);
if ($type === null || $entity instanceof $type) {
$entities[] = $this->getEntity(Uuid\Uuid::fromString($id), $this->rawData[$id]);
}
}
}

Expand Down
10 changes: 7 additions & 3 deletions src/Models/DataStorage/ConnectorPropertiesRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,17 @@ public function findByIdentifier(
*
* @throws MetadataExceptions\FileNotFoundException
*/
public function findAllByConnector(Uuid\UuidInterface $connector): array
{
public function findAllByConnector(
Uuid\UuidInterface $connector,
?string $type = null
): array {
$entities = [];

foreach ($this->rawData as $id => $entity) {
if (array_key_exists('connector', $entity) && $connector->toString() === $entity['connector']) {
$entities[] = $this->getEntity(Uuid\Uuid::fromString($id), $this->rawData[$id]);
if ($type === null || $entity instanceof $type) {
$entities[] = $this->getEntity(Uuid\Uuid::fromString($id), $this->rawData[$id]);
}
}
}

Expand Down
10 changes: 7 additions & 3 deletions src/Models/DataStorage/DevicePropertiesRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,17 @@ public function findByIdentifier(
*
* @throws MetadataExceptions\FileNotFoundException
*/
public function findAllByDevice(Uuid\UuidInterface $device): array
{
public function findAllByDevice(
Uuid\UuidInterface $device,
?string $type = null
): array {
$entities = [];

foreach ($this->rawData as $id => $entity) {
if (array_key_exists('device', $entity) && $device->toString() === $entity['device']) {
$entities[] = $this->getEntity(Uuid\Uuid::fromString($id), $this->rawData[$id]);
if ($type === null || $entity instanceof $type) {
$entities[] = $this->getEntity(Uuid\Uuid::fromString($id), $this->rawData[$id]);
}
}
}

Expand Down
6 changes: 5 additions & 1 deletion src/Models/DataStorage/IChannelPropertiesRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,14 @@ public function findByIdentifier(

/**
* @param Uuid\UuidInterface $channel
* @param string|null $type
*
* @return MetadataEntities\Modules\DevicesModule\IChannelStaticPropertyEntity[]|MetadataEntities\Modules\DevicesModule\IChannelDynamicPropertyEntity[]|MetadataEntities\Modules\DevicesModule\IChannelMappedPropertyEntity[]
*/
public function findAllByChannel(Uuid\UuidInterface $channel): array;
public function findAllByChannel(
Uuid\UuidInterface $channel,
?string $type = null
): array;

/**
* @param Uuid\UuidInterface $id
Expand Down
6 changes: 5 additions & 1 deletion src/Models/DataStorage/IConnectorPropertiesRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,14 @@ public function findByIdentifier(

/**
* @param Uuid\UuidInterface $connector
* @param string|null $type
*
* @return MetadataEntities\Modules\DevicesModule\IConnectorStaticPropertyEntity[]|MetadataEntities\Modules\DevicesModule\IConnectorDynamicPropertyEntity[]|MetadataEntities\Modules\DevicesModule\IConnectorMappedPropertyEntity[]
*/
public function findAllByConnector(Uuid\UuidInterface $connector): array;
public function findAllByConnector(
Uuid\UuidInterface $connector,
?string $type = null
): array;

/**
* @param Uuid\UuidInterface $id
Expand Down
8 changes: 7 additions & 1 deletion src/Models/DataStorage/IDevicePropertiesRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,16 @@ public function findByIdentifier(

/**
* @param Uuid\UuidInterface $device
* @param string|null $type
*
* @return MetadataEntities\Modules\DevicesModule\IDeviceStaticPropertyEntity[]|MetadataEntities\Modules\DevicesModule\IDeviceDynamicPropertyEntity[]|MetadataEntities\Modules\DevicesModule\IDeviceMappedPropertyEntity[]
*
* @phpstan-param class-string $type
*/
public function findAllByDevice(Uuid\UuidInterface $device): array;
public function findAllByDevice(
Uuid\UuidInterface $device,
?string $type = null
): array;

/**
* @param Uuid\UuidInterface $id
Expand Down

0 comments on commit 291bf0b

Please sign in to comment.