|
|
@ -9,7 +9,13 @@ use ReflectionClass; |
|
|
|
|
|
|
|
class SchemaBuilder |
|
|
|
{ |
|
|
|
private static function GetValidKeys() |
|
|
|
/** |
|
|
|
* Goes through the Attribute classes and makes a list of all the Properties they have. |
|
|
|
* This is so if a user adds another variable to the Attribute constructor, it won't appear in the final Schema. |
|
|
|
* |
|
|
|
* @return array[] |
|
|
|
*/ |
|
|
|
private static function GetValidKeys(): array |
|
|
|
{ |
|
|
|
$validDocumentAttributeNames = []; |
|
|
|
$validPropertyAttributeNames = []; |
|
|
@ -21,6 +27,15 @@ class SchemaBuilder |
|
|
|
|
|
|
|
return [$validDocumentAttributeNames, $validPropertyAttributeNames]; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Checks to see if a value is "okay" for a Schema. |
|
|
|
* |
|
|
|
* @param string $key |
|
|
|
* @param mixed $value |
|
|
|
* @param array $valids |
|
|
|
* @return bool |
|
|
|
*/ |
|
|
|
private static function VerifyField(string $key, mixed $value, array $valids): bool |
|
|
|
{ |
|
|
|
if(!in_array(needle: $key, haystack: $valids)) |
|
|
@ -30,6 +45,13 @@ class SchemaBuilder |
|
|
|
|
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Just converts PascalCase to snake_case. |
|
|
|
* |
|
|
|
* @param string $input |
|
|
|
* @return string |
|
|
|
*/ |
|
|
|
private static function PascalCaseToSnakeCase(string $input): string |
|
|
|
{ |
|
|
|
return strtolower(preg_replace('/(?<!^)[A-Z]/', '_$0', $input)); |
|
|
|