Browse Source

bodged comments

pull/2/head
Cerys 4 months ago
parent
commit
915ce12b93
  1. 24
      src/SchemaBuilder/SchemaBuilder.php

24
src/SchemaBuilder/SchemaBuilder.php

@ -9,7 +9,13 @@ use ReflectionClass;
class SchemaBuilder 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 = []; $validDocumentAttributeNames = [];
$validPropertyAttributeNames = []; $validPropertyAttributeNames = [];
@ -21,6 +27,15 @@ class SchemaBuilder
return [$validDocumentAttributeNames, $validPropertyAttributeNames]; 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 private static function VerifyField(string $key, mixed $value, array $valids): bool
{ {
if(!in_array(needle: $key, haystack: $valids)) if(!in_array(needle: $key, haystack: $valids))
@ -30,6 +45,13 @@ class SchemaBuilder
return true; return true;
} }
/**
* Just converts PascalCase to snake_case.
*
* @param string $input
* @return string
*/
private static function PascalCaseToSnakeCase(string $input): string private static function PascalCaseToSnakeCase(string $input): string
{ {
return strtolower(preg_replace('/(?<!^)[A-Z]/', '_$0', $input)); return strtolower(preg_replace('/(?<!^)[A-Z]/', '_$0', $input));

Loading…
Cancel
Save