Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
92.86% |
13 / 14 |
|
75.00% |
3 / 4 |
CRAP | |
0.00% |
0 / 1 |
TagEnumeration | |
92.86% |
13 / 14 |
|
75.00% |
3 / 4 |
9.03 | |
0.00% |
0 / 1 |
addStructValue | |
100.00% |
7 / 7 |
|
100.00% |
1 / 1 |
4 | |||
parseWsdl | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
2 | |||
parsingTag | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
parseEnumeration | |
75.00% |
3 / 4 |
|
0.00% |
0 / 1 |
2.06 |
1 | <?php |
2 | |
3 | declare(strict_types=1); |
4 | |
5 | namespace WsdlToPhp\PackageGenerator\Parser\Wsdl; |
6 | |
7 | use WsdlToPhp\PackageGenerator\Model\Struct; |
8 | use WsdlToPhp\PackageGenerator\Model\StructValue; |
9 | use WsdlToPhp\PackageGenerator\Model\Wsdl; |
10 | use WsdlToPhp\WsdlHandler\Tag\AbstractTag as Tag; |
11 | use WsdlToPhp\WsdlHandler\Tag\TagEnumeration as Enumeration; |
12 | use WsdlToPhp\WsdlHandler\Wsdl as WsdlDocument; |
13 | |
14 | final class TagEnumeration extends AbstractTagParser |
15 | { |
16 | public function addStructValue(Tag $tag, Enumeration $enumeration): void |
17 | { |
18 | // issue #177: first time, the enumeration struct is unknown, |
19 | // it'll be created when addValue is called on the existing struct which is not an enum |
20 | $struct = $this->getModel($tag, $enumeration->getRestrictionParentType()); |
21 | $struct = $struct ? $struct : $this->getModel($tag); |
22 | if (!$struct instanceof Struct) { |
23 | return; |
24 | } |
25 | |
26 | // issue #177: the aim of redefining the $struct variable is to keep the reference to the right struct |
27 | $struct = $struct->addValue($enumeration->getValue()); |
28 | if (($value = $struct->getValue($enumeration->getValue())) instanceof StructValue) { |
29 | $this->parseTagAttributes($enumeration, $value); |
30 | } |
31 | } |
32 | |
33 | protected function parseWsdl(Wsdl $wsdl): void |
34 | { |
35 | foreach ($this->getTags() as $tag) { |
36 | $this->parseEnumeration($tag); |
37 | } |
38 | } |
39 | |
40 | protected function parsingTag(): string |
41 | { |
42 | return WsdlDocument::TAG_ENUMERATION; |
43 | } |
44 | |
45 | protected function parseEnumeration(Enumeration $enumeration): void |
46 | { |
47 | $parent = $enumeration->getSuitableParent(); |
48 | |
49 | if (!$parent instanceof Tag) { |
50 | return; |
51 | } |
52 | |
53 | $this->addStructValue($parent, $enumeration); |
54 | } |
55 | } |