Initial Commit

This commit is contained in:
Netkas 2023-06-04 14:23:51 -04:00
parent 93a0b9be02
commit 6e599b2c0c
No known key found for this signature in database
GPG key ID: 5DAF58535614062B
99 changed files with 10836 additions and 4 deletions

View file

@ -0,0 +1,60 @@
<?php
namespace FederationLib\Classes;
use FederationLib\Enums\Standard\PeerType;
use FederationLib\Enums\Standard\InternetPeerType;
use FederationLib\Enums\Standard\PeerAssociationType;
use FederationLib\Enums\Standard\UserPeerType;
class Validate
{
/**
* Determines the entity type based on the entity type string.
*
* @param string $entity_type
* @return string
*/
public static function getEntityType(string $entity_type): string
{
if(in_array($entity_type, InternetPeerType::ALL))
{
return PeerType::INTERNET;
}
if(in_array($entity_type, UserPeerType::ALL))
{
return PeerType::USER;
}
return PeerType::UNKNOWN;
}
/**
* Determines if the entity type is valid and supported.
*
* @param string $entity_type
* @return bool
*/
public static function validateEntityType(string $entity_type): bool
{
if(self::getEntityType($entity_type) === PeerType::UNKNOWN)
return false;
return true;
}
/**
* Validates the peer association type.
*
* @param string $type
* @return bool
*/
public static function peerAssociationType(string $type): bool
{
if(in_array(strtolower($type), PeerAssociationType::ALL))
return true;
return false;
}
}