Skip to content

Commit

Permalink
Merge pull request #164 from Vitexus/patch-1
Browse files Browse the repository at this point in the history
The Choice element was missing in process
  • Loading branch information
goetas authored Oct 16, 2023
2 parents 3ae1d58 + f702c79 commit 09d550e
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/Php/PhpConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use GoetasWebservices\XML\XSDReader\Schema\Element\ElementRef;
use GoetasWebservices\XML\XSDReader\Schema\Element\ElementSingle;
use GoetasWebservices\XML\XSDReader\Schema\Element\Group;
use GoetasWebservices\XML\XSDReader\Schema\Element\Choice;
use GoetasWebservices\XML\XSDReader\Schema\Item;
use GoetasWebservices\XML\XSDReader\Schema\Schema;
use GoetasWebservices\XML\XSDReader\Schema\Type\BaseComplexType;
Expand Down Expand Up @@ -118,6 +119,21 @@ private function visitTypeBase(PHPClass $class, Type $type)
}
}

/**
* Process xsd:complexType xsd:choice xsd:element
*
* @param PHPClass $class
* @param Schema $schema
* @param Choice $choice
*/
private function visitChoice(PHPClass $class, Schema $schema, Choice $choice)
{
foreach ($choice->getElements() as $choiceOption) {
$property = $this->visitElement($class, $schema, $choiceOption);
$class->addProperty($property);
}
}

private function visitGroup(PHPClass $class, Schema $schema, Group $group)
{
foreach ($group->getElements() as $childGroup) {
Expand Down Expand Up @@ -304,7 +320,9 @@ private function visitComplexType(PHPClass $class, ComplexType $type)
{
$schema = $type->getSchema();
foreach ($type->getElements() as $element) {
if ($element instanceof Group) {
if ($element instanceof Choice) {
$this->visitChoice($class, $schema, $element);
} elseif ($element instanceof Group) {
$this->visitGroup($class, $schema, $element);
} else {
$property = $this->visitElement($class, $schema, $element);
Expand Down

0 comments on commit 09d550e

Please sign in to comment.