From b757207f8c287ccdac0a7f728c9a6aeab02810d2 Mon Sep 17 00:00:00 2001 From: Artem Otliaguzov Date: Wed, 8 Jan 2025 16:40:54 +0100 Subject: [PATCH] make check function for ServiceName and ServiceDescription --- app/Traits/ValidatorTrait.php | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/app/Traits/ValidatorTrait.php b/app/Traits/ValidatorTrait.php index 7d5dbcd..36f417b 100644 --- a/app/Traits/ValidatorTrait.php +++ b/app/Traits/ValidatorTrait.php @@ -766,16 +766,29 @@ public function checkServiceProviderRequestedAttributeNameValueDuplicity(object } } - public function checkServiceNameAttributeForContentExistence(object $xpath): void - { - foreach ($xpath->query('/md:EntityDescriptor/md:SPSSODescriptor/md:AttributeConsumingService/md:ServiceName') as $attribute) { - if (empty($attribute->nodeValue)) { - $this->error .= 'ServiceName attribute is empty please fill the attribute. '; + + public function checkAttributeForContentExistence (mixed $attributes):void{ + + foreach ($attributes as $attribute) { + if(empty($attribute->nodeValue)){ + $this->error .= " $attribute->localName attribute is empty please fill the attribute. "; break; } } + } + public function checkServiceNameAttributeForContentExistence(object $xpath): void + { + $this->checkAttributeForContentExistence($xpath->query('/md:EntityDescriptor/md:SPSSODescriptor/md:AttributeConsumingService/md:ServiceName')); + } + public function checkServiceDescriptionAttributeForContentExistence(object $xpath): void + { + $this->checkAttributeForContentExistence($xpath->query('/md:EntityDescriptor/md:SPSSODescriptor/md:AttributeConsumingService/md:ServiceDescription')); + } + + + public function generateResult(): void { if (empty($this->error)) { @@ -807,6 +820,7 @@ public function validateMetadata(string $metadata): string $this->checkOneEntityAttributesElementPerExtensions($xpath); $this->checkServiceProviderRequestedAttributeNameValueDuplicity($xpath); $this->checkServiceNameAttributeForContentExistence($xpath); + $this->checkServiceDescriptionAttributeForContentExistence($xpath); $this->generateResult(); }