Skip to content
This repository has been archived by the owner on Oct 12, 2023. It is now read-only.

Commit

Permalink
Ignore non switch devices (#12)
Browse files Browse the repository at this point in the history
* Update ApiClient.php

* Update DeviceFactory.php
  • Loading branch information
l00k authored Jan 14, 2021
1 parent 753948a commit e7245dc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/ApiClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ public function discoverDevices(): array

$devices = [];
foreach ($response['payload']['devices'] as $device) {
$devices[] = $this->deviceFactory->fromArray($device);
$deviceData = $this->deviceFactory->fromArray($device);
if ($deviceData) {
$devices[] = $deviceData;
}
}

return $devices;
Expand Down
2 changes: 1 addition & 1 deletion src/Device/DeviceFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

class DeviceFactory
{
public function fromArray(array $data): AbstractDevice
public function fromArray(array $data): ?AbstractDevice
{
$device = null;
switch ($data['dev_type']) {
Expand Down

0 comments on commit e7245dc

Please sign in to comment.