From 65f3d9e29690dca76f4ce3759f0c3fc1ae476ff6 Mon Sep 17 00:00:00 2001 From: Cerys Date: Sat, 30 Nov 2024 02:12:36 +0000 Subject: [PATCH] started work on being able to generate schema URLs --- examples/Schemas/Message.php | 2 +- examples/Schemas/Organisation.php | 4 ++-- phpunit.xml | 10 ++++++++++ src/Attributes/SchemaDocument.php | 2 ++ src/Utilities/URLHandling.php | 24 ++++++++++++++++++++++++ tests/SchemaURITest.php | 20 ++++++++++++++++++++ tests/bootstrap.php | 3 +++ 7 files changed, 62 insertions(+), 3 deletions(-) create mode 100644 phpunit.xml create mode 100644 src/Utilities/URLHandling.php create mode 100644 tests/SchemaURITest.php create mode 100644 tests/bootstrap.php diff --git a/examples/Schemas/Message.php b/examples/Schemas/Message.php index 6381b9e..ca13c2c 100644 --- a/examples/Schemas/Message.php +++ b/examples/Schemas/Message.php @@ -9,7 +9,7 @@ use Darksparrow\AuxiliumSchemaBuilder\Attributes\SchemaDocument; use Darksparrow\AuxiliumSchemaBuilder\Attributes\SchemaDocumentField; #[SchemaDocument( - Name: "Message", + Name: "message", MimeType: "message/rfc822", )] class Message diff --git a/examples/Schemas/Organisation.php b/examples/Schemas/Organisation.php index b374a54..d9ff4e2 100644 --- a/examples/Schemas/Organisation.php +++ b/examples/Schemas/Organisation.php @@ -1,4 +1,4 @@ - + + + tests + + + diff --git a/src/Attributes/SchemaDocument.php b/src/Attributes/SchemaDocument.php index 80e9d89..4b7e554 100644 --- a/src/Attributes/SchemaDocument.php +++ b/src/Attributes/SchemaDocument.php @@ -10,6 +10,7 @@ use PhpParser\Node\Name; #[\Attribute] class SchemaDocument extends Attribute { + public string $Name; public int $MaxSize; public string $Comment; public string $MimeType; @@ -21,6 +22,7 @@ class SchemaDocument extends Attribute string $MimeType = "" ) { + $this->Name = $Name; $this->MaxSize = $MaxSize; $this->Comment = $Comment; $this->MimeType = $MimeType; diff --git a/src/Utilities/URLHandling.php b/src/Utilities/URLHandling.php new file mode 100644 index 0000000..cd299d8 --- /dev/null +++ b/src/Utilities/URLHandling.php @@ -0,0 +1,24 @@ +getAttributes() as $attribute) + { + if($attribute->getName() === SchemaDocument::class) + { + $name = $attribute->getArguments()["Name"]; + return self::$URLBase . $name . ".json"; + } + } + die(); + } +} diff --git a/tests/SchemaURITest.php b/tests/SchemaURITest.php new file mode 100644 index 0000000..5e472b4 --- /dev/null +++ b/tests/SchemaURITest.php @@ -0,0 +1,20 @@ +