Skip to content

Commit a054c01

Browse files
committed
fix metadata tests
1 parent a7b8b8f commit a054c01

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

src/Metadata/Tests/Extractor/Adapter/XmlResourceAdapter.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,31 @@ private function buildGraphQlOperations(\SimpleXMLElement $resource, array $valu
441441
}
442442
}
443443

444+
private function buildMcp(\SimpleXMLElement $resource, ?array $values): void
445+
{
446+
if (!$values) {
447+
return;
448+
}
449+
450+
$node = $resource->addChild('mcpOperations');
451+
foreach ($values as $value) {
452+
$child = $node->addChild('mcpOperation');
453+
foreach ($value as $index => $data) {
454+
if (method_exists($this, 'build'.ucfirst($index))) {
455+
$this->{'build'.ucfirst($index)}($child, $data);
456+
continue;
457+
}
458+
459+
if (\is_string($data) || null === $data || is_numeric($data) || \is_bool($data)) {
460+
$child->addAttribute($index, $this->parse($data));
461+
continue;
462+
}
463+
464+
throw new \LogicException(\sprintf('Cannot adapt mcpOperation attribute or child "%s". Please create a "%s" method in %s.', $index, 'build'.ucfirst($index), self::class));
465+
}
466+
}
467+
}
468+
444469
private function buildOperations(\SimpleXMLElement $resource, array $values): void
445470
{
446471
$node = $resource->addChild('operations');

src/Metadata/Tests/Extractor/Adapter/resources.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,3 +344,4 @@ resources:
344344
another_custom_property:
345345
'Lorem ipsum': 'Dolor sit amet'
346346
map: null
347+
mcp: null

0 commit comments

Comments
 (0)