Browse Source

missed some more lol, so glad it's not prod! 😅

master
Cerys 4 months ago
parent
commit
c7a1337652
  1. 17
      src/Exceptions/SchemaDocumentFieldNameUnsetException.php
  2. 2
      src/Exceptions/SchemaDocumentNameUnsetException.php
  3. 8
      src/SchemaBuilder/SchemaBuilder.php

17
src/Exceptions/SchemaDocumentFieldNameUnsetException.php

@ -0,0 +1,17 @@
<?php
namespace Darksparrow\AuxiliumSchemaBuilder\Exceptions;
use Exception;
class SchemaDocumentFieldNameUnsetException extends Exception
{
public function __construct(
string $message = "The Name field is required.",
int $code = 422
) {
parent::__construct($message, $code);
$this->message = "$message";
$this->code = $code;
}
}

2
src/Exceptions/SchemaNameUnsetException.php → src/Exceptions/SchemaDocumentNameUnsetException.php

@ -4,7 +4,7 @@ namespace Darksparrow\AuxiliumSchemaBuilder\Exceptions;
use Exception; use Exception;
class SchemaNameUnsetException extends Exception class SchemaDocumentNameUnsetException extends Exception
{ {
public function __construct( public function __construct(
string $message = "The Name field is required.", string $message = "The Name field is required.",

8
src/SchemaBuilder/SchemaBuilder.php

@ -2,7 +2,7 @@
namespace Darksparrow\AuxiliumSchemaBuilder\SchemaBuilder; namespace Darksparrow\AuxiliumSchemaBuilder\SchemaBuilder;
use Darksparrow\AuxiliumSchemaBuilder\Exceptions\SchemaNameUnsetException; use Darksparrow\AuxiliumSchemaBuilder\Exceptions\SchemaDocumentFieldNameUnsetException;
use Darksparrow\AuxiliumSchemaBuilder\Attributes\SchemaDocument; use Darksparrow\AuxiliumSchemaBuilder\Attributes\SchemaDocument;
use Darksparrow\AuxiliumSchemaBuilder\Attributes\SchemaDocumentField; use Darksparrow\AuxiliumSchemaBuilder\Attributes\SchemaDocumentField;
use JetBrains\PhpStorm\NoReturn; use JetBrains\PhpStorm\NoReturn;
@ -60,7 +60,7 @@ class SchemaBuilder
/** /**
* @throws SchemaNameUnsetException * @throws SchemaDocumentFieldNameUnsetException
*/ */
public static function GenerateSchema(object $targetSchema): array public static function GenerateSchema(object $targetSchema): array
{ {
@ -85,7 +85,7 @@ class SchemaBuilder
foreach ($property->getAttributes() as $attribute) foreach ($property->getAttributes() as $attribute)
{ {
if($attribute->getName() != "Darksparrow\DeegraphPHP\SchemaBuilder\Attributes\SchemaDocumentField") if($attribute->getName() != "Darksparrow\AuxiliumSchemaBuilder\Attributes\SchemaDocumentField")
continue; continue;
foreach($attribute->getArguments() as $key=>$value) foreach($attribute->getArguments() as $key=>$value)
@ -101,7 +101,7 @@ class SchemaBuilder
} }
} }
if($propertyName == "") if($propertyName == "")
throw new SchemaNameUnsetException(); throw new SchemaDocumentFieldNameUnsetException();
$schema["$propertyName"] = $propertySchema; $schema["$propertyName"] = $propertySchema;
} }

Loading…
Cancel
Save