|
@ -7,6 +7,7 @@ use Darksparrow\AuxiliumSchemaBuilder\Attributes\SchemaDocument; |
|
|
use Darksparrow\AuxiliumSchemaBuilder\Attributes\SchemaDocumentField; |
|
|
use Darksparrow\AuxiliumSchemaBuilder\Attributes\SchemaDocumentField; |
|
|
use Darksparrow\AuxiliumSchemaBuilder\Utilities\URLHandling; |
|
|
use Darksparrow\AuxiliumSchemaBuilder\Utilities\URLHandling; |
|
|
use JetBrains\PhpStorm\NoReturn; |
|
|
use JetBrains\PhpStorm\NoReturn; |
|
|
|
|
|
use PHPUnit\Util\Exception; |
|
|
use ReflectionClass; |
|
|
use ReflectionClass; |
|
|
|
|
|
|
|
|
class SchemaBuilder |
|
|
class SchemaBuilder |
|
@ -81,6 +82,9 @@ class SchemaBuilder |
|
|
*/ |
|
|
*/ |
|
|
foreach ($reflection->getProperties() as $property) |
|
|
foreach ($reflection->getProperties() as $property) |
|
|
{ |
|
|
{ |
|
|
|
|
|
$classNameRegex = '/^([\\]*)?[a-zA-Z_][a-zA-Z0-9_]*)(([\\]*[a-zA-Z0-9_]*)*)$/'; |
|
|
|
|
|
$urlRegex = '/^https?:\/\/[^\s$.?#].[^\s]*$/i'; |
|
|
|
|
|
|
|
|
$propertyName = ""; |
|
|
$propertyName = ""; |
|
|
$propertySchema = []; |
|
|
$propertySchema = []; |
|
|
|
|
|
|
|
@ -101,24 +105,38 @@ class SchemaBuilder |
|
|
"@comment" => $value->Comment, |
|
|
"@comment" => $value->Comment, |
|
|
"@valid_schemas" => $value->ValidSchemas, |
|
|
"@valid_schemas" => $value->ValidSchemas, |
|
|
]; |
|
|
]; |
|
|
|
|
|
$propertySchema["@valid_schemas"] = []; |
|
|
|
|
|
foreach($value as $validSchema) |
|
|
|
|
|
{ |
|
|
|
|
|
if (preg_match($classNameRegex, $validSchema)) |
|
|
|
|
|
$propertySchema["@valid_schemas"][] = URLHandling::GetURLForSchema($validSchema); |
|
|
|
|
|
elseif (preg_match($urlRegex, $validSchema)) |
|
|
|
|
|
$propertySchema["@valid_schemas"][] = $validSchema; |
|
|
|
|
|
else |
|
|
|
|
|
$propertySchema["@valid_schemas"][] = "test123"; |
|
|
} |
|
|
} |
|
|
elseif(self::VerifyField($key, $value, $validKeys[1])) |
|
|
} |
|
|
|
|
|
elseif($key == "Existance") |
|
|
{ |
|
|
{ |
|
|
$propertySchema["@" . self::PascalCaseToSnakeCase(input: $key)] = $value; |
|
|
$propertySchema["#"] = $value->value; |
|
|
} |
|
|
} |
|
|
elseif($key == "ValidSchemas") |
|
|
elseif($key == "ValidSchemas") |
|
|
{ |
|
|
{ |
|
|
$propertySchema["@valid_schemas"] = []; |
|
|
$propertySchema["@valid_schemas"] = []; |
|
|
$classNameRegex = '/^(\\\\?[A-Z][a-zA-Z0-9_]*)((\\\\[A-Z][a-zA-Z0-9_]*)*)$/'; |
|
|
|
|
|
$urlRegex = '/^https?:\/\/[^\s$.?#].[^\s]*$/i'; |
|
|
|
|
|
foreach($value as $validSchema) |
|
|
foreach($value as $validSchema) |
|
|
{ |
|
|
{ |
|
|
if (preg_match($classNameRegex, $validSchema)) |
|
|
if (preg_match($classNameRegex, $validSchema)) |
|
|
$propertySchema["@valid_schemas"][] = URLHandling::GetURLForSchema($validSchema); |
|
|
$propertySchema["@valid_schemas"][] = URLHandling::GetURLForSchema($validSchema); |
|
|
elseif (preg_match($urlRegex, $validSchema)) |
|
|
elseif (preg_match($urlRegex, $validSchema)) |
|
|
$propertySchema["@valid_schemas"][] = $validSchema; |
|
|
$propertySchema["@valid_schemas"][] = $validSchema; |
|
|
|
|
|
else |
|
|
|
|
|
$propertySchema["@valid_schemas"][] = "test123"; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
elseif(self::VerifyField($key, $value, $validKeys[1])) |
|
|
|
|
|
{ |
|
|
|
|
|
$propertySchema["@" . self::PascalCaseToSnakeCase(input: $key)] = $value; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
if($propertyName == "") |
|
|
if($propertyName == "") |
|
|