Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
92.00% |
23 / 25 |
|
66.67% |
2 / 3 |
CRAP | |
0.00% |
0 / 1 |
TagList | |
92.00% |
23 / 25 |
|
66.67% |
2 / 3 |
11.06 | |
0.00% |
0 / 1 |
parseList | |
90.91% |
20 / 22 |
|
0.00% |
0 / 1 |
8.05 | |||
parseWsdl | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
2 | |||
parsingTag | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 |
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\StructAttribute; |
9 | use WsdlToPhp\PackageGenerator\Model\Wsdl; |
10 | use WsdlToPhp\WsdlHandler\Tag\AbstractTag; |
11 | use WsdlToPhp\WsdlHandler\Tag\TagList as ListTag; |
12 | use WsdlToPhp\WsdlHandler\Wsdl as WsdlDocument; |
13 | |
14 | final class TagList extends AbstractTagParser |
15 | { |
16 | public function parseList(ListTag $tag): void |
17 | { |
18 | $parent = $tag->getSuitableParent(); |
19 | if (!$parent instanceof AbstractTag) { |
20 | return; |
21 | } |
22 | |
23 | $parentParent = $parent->getSuitableParent(); |
24 | $model = $this->getModel($parent); |
25 | if (is_null($model) && $parentParent instanceof AbstractTag) { |
26 | $model = $this->getModel($parentParent); |
27 | } |
28 | |
29 | if (!$model instanceof Struct) { |
30 | return; |
31 | } |
32 | |
33 | $itemType = $tag->getItemType(); |
34 | $struct = $this->getStructByName($itemType); |
35 | |
36 | $type = $struct instanceof Struct ? $struct->getName() : $itemType; |
37 | if ($parentParent instanceof AbstractTag && ($attribute = $model->getAttribute($parent->getAttributeName())) instanceof StructAttribute) { |
38 | $attribute |
39 | ->setContainsElements(true) |
40 | ->setType($type) |
41 | ->setInheritance($type) |
42 | ; |
43 | } else { |
44 | $model |
45 | ->setList($type) |
46 | ->setInheritance(sprintf('%s[]', $type)) |
47 | ; |
48 | } |
49 | } |
50 | |
51 | protected function parseWsdl(Wsdl $wsdl): void |
52 | { |
53 | foreach ($this->getTags() as $tag) { |
54 | $this->parseList($tag); |
55 | } |
56 | } |
57 | |
58 | protected function parsingTag(): string |
59 | { |
60 | return WsdlDocument::TAG_LIST; |
61 | } |
62 | } |