Refactor getIncomingChannels to improve peer address validation logic
https://github.com/nosial/Socialbox-PHP/issues/25
This commit is contained in:
parent
ea3a070d13
commit
6be9e90ceb
1 changed files with 5 additions and 4 deletions
|
@ -335,14 +335,15 @@
|
||||||
*/
|
*/
|
||||||
public static function getIncomingChannels(string|PeerAddress $peerAddress, int $page=1, int $limit=100): array
|
public static function getIncomingChannels(string|PeerAddress $peerAddress, int $page=1, int $limit=100): array
|
||||||
{
|
{
|
||||||
|
if(is_string($peerAddress) && !Validator::validatePeerAddress($peerAddress))
|
||||||
|
{
|
||||||
|
throw new InvalidArgumentException('Invalid Peer Address');
|
||||||
|
}
|
||||||
|
|
||||||
if($peerAddress instanceof PeerAddress)
|
if($peerAddress instanceof PeerAddress)
|
||||||
{
|
{
|
||||||
$peerAddress = $peerAddress->getAddress();
|
$peerAddress = $peerAddress->getAddress();
|
||||||
}
|
}
|
||||||
elseif(!Validator::validatePeerAddress($peerAddress))
|
|
||||||
{
|
|
||||||
throw new InvalidArgumentException('Invalid Peer Address');
|
|
||||||
}
|
|
||||||
|
|
||||||
if($page < 1)
|
if($page < 1)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue