Skip to content

Commit

Permalink
[viera-connector] Fixed viera device installation (#303)
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Aug 27, 2024
1 parent ae0c95c commit d666ba7
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/API/V1Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
use Nette;
use Ramsey\Uuid;
use function array_merge;
use function assert;
use function is_string;
use function preg_match;
use function strtolower;

Expand Down Expand Up @@ -91,7 +93,8 @@ public static function parse(

if (V1Validator::validateChannelPart($topic)) {
preg_match(V1Validator::CHANNEL_PARTIAL_REGEXP, $topic, $matches);
[, $device] = $matches;
[, $device] = $matches + [null, null];

Check warning on line 96 in src/API/V1Parser.php

View workflow job for this annotation

GitHub Actions / PHP Tests For Mutants (8.2, ubuntu-latest) / Mutation Tests (PHP 8.2)

Escaped Mutant for Mutator "ArrayItemRemoval": --- Original +++ New @@ @@ } if (V1Validator::validateChannelPart($topic)) { preg_match(V1Validator::CHANNEL_PARTIAL_REGEXP, $topic, $matches); - [, $device] = $matches + [null, null]; + [, $device] = $matches + [null]; assert(is_string($device)); if (V1Validator::validateChannelAttribute($topic)) { return array_merge(self::parseChannelAttribute($connector, $device, $topic, $payload), ['retained' => $retained]);
assert(is_string($device));

if (V1Validator::validateChannelAttribute($topic)) {
return array_merge(
Expand Down Expand Up @@ -125,7 +128,8 @@ private static function parseDeviceAttribute(
): array
{
preg_match(V1Validator::DEVICE_ATTRIBUTE_REGEXP, $topic, $matches);
[, $device, $attribute] = $matches;
[, $device, $attribute] = $matches + [null, null, null];

Check warning on line 131 in src/API/V1Parser.php

View workflow job for this annotation

GitHub Actions / PHP Tests For Mutants (8.2, ubuntu-latest) / Mutation Tests (PHP 8.2)

Escaped Mutant for Mutator "ArrayItemRemoval": --- Original +++ New @@ @@ private static function parseDeviceAttribute(Uuid\UuidInterface $connector, string $topic, string $payload) : array { preg_match(V1Validator::DEVICE_ATTRIBUTE_REGEXP, $topic, $matches); - [, $device, $attribute] = $matches + [null, null, null]; + [, $device, $attribute] = $matches + [null, null]; assert(is_string($device) && is_string($attribute)); return ['connector' => $connector, 'device' => $device, 'attribute' => $attribute, 'value' => $payload]; }
assert(is_string($device) && is_string($attribute));

Check warning on line 132 in src/API/V1Parser.php

View workflow job for this annotation

GitHub Actions / PHP Tests For Mutants (8.2, ubuntu-latest) / Mutation Tests (PHP 8.2)

Escaped Mutant for Mutator "LogicalAnd": --- Original +++ New @@ @@ { preg_match(V1Validator::DEVICE_ATTRIBUTE_REGEXP, $topic, $matches); [, $device, $attribute] = $matches + [null, null, null]; - assert(is_string($device) && is_string($attribute)); + assert(is_string($device) || is_string($attribute)); return ['connector' => $connector, 'device' => $device, 'attribute' => $attribute, 'value' => $payload]; } /**

return [
'connector' => $connector,
Expand All @@ -145,7 +149,8 @@ private static function parseDeviceHardwareInfo(
): array
{
preg_match(V1Validator::DEVICE_HW_INFO_REGEXP, $topic, $matches);
[, $device, $hardware] = $matches;
[, $device, $hardware] = $matches + [null, null, null];

Check warning on line 152 in src/API/V1Parser.php

View workflow job for this annotation

GitHub Actions / PHP Tests For Mutants (8.2, ubuntu-latest) / Mutation Tests (PHP 8.2)

Escaped Mutant for Mutator "ArrayItemRemoval": --- Original +++ New @@ @@ private static function parseDeviceHardwareInfo(Uuid\UuidInterface $connector, string $topic, string $payload) : array { preg_match(V1Validator::DEVICE_HW_INFO_REGEXP, $topic, $matches); - [, $device, $hardware] = $matches + [null, null, null]; + [, $device, $hardware] = $matches + [null, null]; assert(is_string($device) && is_string($hardware)); return ['connector' => $connector, 'device' => $device, 'extension' => Types\ExtensionType::FASTYBIRD_HARDWARE->value, 'parameter' => $hardware, 'value' => Helpers\Payload::cleanName(strtolower($payload))]; }
assert(is_string($device) && is_string($hardware));

Check warning on line 153 in src/API/V1Parser.php

View workflow job for this annotation

GitHub Actions / PHP Tests For Mutants (8.2, ubuntu-latest) / Mutation Tests (PHP 8.2)

Escaped Mutant for Mutator "LogicalAnd": --- Original +++ New @@ @@ { preg_match(V1Validator::DEVICE_HW_INFO_REGEXP, $topic, $matches); [, $device, $hardware] = $matches + [null, null, null]; - assert(is_string($device) && is_string($hardware)); + assert(is_string($device) || is_string($hardware)); return ['connector' => $connector, 'device' => $device, 'extension' => Types\ExtensionType::FASTYBIRD_HARDWARE->value, 'parameter' => $hardware, 'value' => Helpers\Payload::cleanName(strtolower($payload))]; } /**

return [
'connector' => $connector,
Expand All @@ -166,7 +171,8 @@ private static function parseDeviceFirmwareInfo(
): array
{
preg_match(V1Validator::DEVICE_FW_INFO_REGEXP, $topic, $matches);
[, $device, $firmware] = $matches;
[, $device, $firmware] = $matches + [null, null, null];

Check warning on line 174 in src/API/V1Parser.php

View workflow job for this annotation

GitHub Actions / PHP Tests For Mutants (8.2, ubuntu-latest) / Mutation Tests (PHP 8.2)

Escaped Mutant for Mutator "ArrayItemRemoval": --- Original +++ New @@ @@ private static function parseDeviceFirmwareInfo(Uuid\UuidInterface $connector, string $topic, string $payload) : array { preg_match(V1Validator::DEVICE_FW_INFO_REGEXP, $topic, $matches); - [, $device, $firmware] = $matches + [null, null, null]; + [, $device, $firmware] = $matches + [null, null]; assert(is_string($device) && is_string($firmware)); return ['connector' => $connector, 'device' => $device, 'extension' => Types\ExtensionType::FASTYBIRD_FIRMWARE->value, 'parameter' => $firmware, 'value' => Helpers\Payload::cleanName(strtolower($payload))]; }
assert(is_string($device) && is_string($firmware));

Check warning on line 175 in src/API/V1Parser.php

View workflow job for this annotation

GitHub Actions / PHP Tests For Mutants (8.2, ubuntu-latest) / Mutation Tests (PHP 8.2)

Escaped Mutant for Mutator "LogicalAnd": --- Original +++ New @@ @@ { preg_match(V1Validator::DEVICE_FW_INFO_REGEXP, $topic, $matches); [, $device, $firmware] = $matches + [null, null, null]; - assert(is_string($device) && is_string($firmware)); + assert(is_string($device) || is_string($firmware)); return ['connector' => $connector, 'device' => $device, 'extension' => Types\ExtensionType::FASTYBIRD_FIRMWARE->value, 'parameter' => $firmware, 'value' => Helpers\Payload::cleanName(strtolower($payload))]; } /**

return [
'connector' => $connector,
Expand Down Expand Up @@ -218,7 +224,8 @@ private static function parseChannelAttribute(
): array
{
preg_match(V1Validator::CHANNEL_ATTRIBUTE_REGEXP, $topic, $matches);
[, , $channel, $attribute] = $matches;
[, , $channel, $attribute] = $matches + [null, null, null, null];
assert(is_string($channel) && is_string($attribute));

return [
'connector' => $connector,
Expand Down

0 comments on commit d666ba7

Please sign in to comment.