Added method \FederationLib\Classes > Validate > associationType()
Refactored \FederationLib\Classes > Validate
This commit is contained in:
parent
e6a869c216
commit
a2f4b2b685
1 changed files with 25 additions and 12 deletions
|
@ -5,7 +5,6 @@
|
||||||
use FederationLib\Enums\Standard\PeerType;
|
use FederationLib\Enums\Standard\PeerType;
|
||||||
use FederationLib\Enums\Standard\InternetPeerType;
|
use FederationLib\Enums\Standard\InternetPeerType;
|
||||||
use FederationLib\Enums\Standard\PeerAssociationType;
|
use FederationLib\Enums\Standard\PeerAssociationType;
|
||||||
use FederationLib\Enums\Standard\PermissionRole;
|
|
||||||
use FederationLib\Enums\Standard\UserPeerType;
|
use FederationLib\Enums\Standard\UserPeerType;
|
||||||
use FederationLib\Exceptions\Standard\InvalidPeerMetadataException;
|
use FederationLib\Exceptions\Standard\InvalidPeerMetadataException;
|
||||||
|
|
||||||
|
@ -40,10 +39,7 @@
|
||||||
*/
|
*/
|
||||||
public static function validateEntityType(string $entity_type): bool
|
public static function validateEntityType(string $entity_type): bool
|
||||||
{
|
{
|
||||||
if(self::getEntityType($entity_type) === PeerType::UNKNOWN)
|
return self::getEntityType($entity_type) !== PeerType::UNKNOWN;
|
||||||
return false;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -55,7 +51,9 @@
|
||||||
public static function peerAssociationType(string $type): bool
|
public static function peerAssociationType(string $type): bool
|
||||||
{
|
{
|
||||||
if (in_array(strtolower($type), PeerAssociationType::ALL))
|
if (in_array(strtolower($type), PeerAssociationType::ALL))
|
||||||
|
{
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -112,7 +110,7 @@
|
||||||
* @return void
|
* @return void
|
||||||
* @throws InvalidPeerMetadataException
|
* @throws InvalidPeerMetadataException
|
||||||
*/
|
*/
|
||||||
public static function validateMetadata(array $data, array $required, array $optional): void
|
public static function metadata(array $data, array $required, array $optional): void
|
||||||
{
|
{
|
||||||
foreach($required as $property => $type)
|
foreach($required as $property => $type)
|
||||||
{
|
{
|
||||||
|
@ -136,4 +134,19 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validates if the given association type is valid.
|
||||||
|
*
|
||||||
|
* @param string $type
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public static function associationType(string $type): bool
|
||||||
|
{
|
||||||
|
if(in_array($type, PeerAssociationType::ALL))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue