-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactored async await in discovery (#309)
- Loading branch information
1 parent
d4b3fa1
commit 264ea3d
Showing
3 changed files
with
131 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
/** | ||
* LocalDevice.php | ||
* | ||
* @license More in LICENSE.md | ||
* @copyright https://www.fastybird.com | ||
* @author Adam Kadlec <[email protected]> | ||
* @package FastyBird:VieraConnector! | ||
* @subpackage ValueObjects | ||
* @since 1.0.0 | ||
* | ||
* @date 29.08.24 | ||
*/ | ||
|
||
namespace FastyBird\Connector\Viera\ValueObjects; | ||
|
||
use Orisai\ObjectMapper; | ||
use function strtolower; | ||
|
||
/** | ||
* Local device info | ||
* | ||
* @package FastyBird:VieraConnector! | ||
* @subpackage ValueObjects | ||
* | ||
* @author Adam Kadlec <[email protected]> | ||
*/ | ||
final readonly class LocalDevice implements ObjectMapper\MappedObject | ||
{ | ||
|
||
public function __construct( | ||
#[ObjectMapper\Rules\StringValue(notEmpty: true)] | ||
private string $id, | ||
#[ObjectMapper\Rules\StringValue(notEmpty: true)] | ||
private string $host, | ||
#[ObjectMapper\Rules\IntValue(castNumericString: true)] | ||
private int $port, | ||
) | ||
{ | ||
} | ||
|
||
public function getId(): string | ||
{ | ||
return $this->id; | ||
} | ||
|
||
public function getHost(): string | ||
{ | ||
return $this->host; | ||
} | ||
|
||
public function getPort(): int | ||
{ | ||
return $this->port; | ||
} | ||
|
||
/** | ||
* @return array<string, string|int> | ||
*/ | ||
public function __serialize(): array | ||
{ | ||
return [ | ||
'id' => $this->getId(), | ||
'host' => strtolower($this->getHost()), | ||
'port' => $this->getPort(), | ||
]; | ||
} | ||
|
||
} |