Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
26 / 26 |
|
100.00% |
4 / 4 |
CRAP | |
100.00% |
1 / 1 |
TagHeader | |
100.00% |
26 / 26 |
|
100.00% |
4 / 4 |
9 | |
100.00% |
1 / 1 |
parseHeader | |
100.00% |
21 / 21 |
|
100.00% |
1 / 1 |
5 | |||
parseWsdl | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
2 | |||
parsingTag | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
isSoapHeaderAlreadyDefined | |
100.00% |
2 / 2 |
|
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\Method; |
8 | use WsdlToPhp\PackageGenerator\Model\Wsdl; |
9 | use WsdlToPhp\WsdlHandler\Tag\TagHeader as Header; |
10 | use WsdlToPhp\WsdlHandler\Tag\TagInput as Input; |
11 | use WsdlToPhp\WsdlHandler\Tag\TagOperation as Operation; |
12 | use WsdlToPhp\WsdlHandler\Wsdl as WsdlDocument; |
13 | |
14 | final class TagHeader extends AbstractTagParser |
15 | { |
16 | public const META_SOAP_HEADERS = 'SOAPHeaders'; |
17 | public const META_SOAP_HEADER_NAMES = 'SOAPHeaderNames'; |
18 | public const META_SOAP_HEADER_TYPES = 'SOAPHeaderTypes'; |
19 | public const META_SOAP_HEADER_NAMESPACES = 'SOAPHeaderNamespaces'; |
20 | |
21 | public function parseHeader(Header $header): void |
22 | { |
23 | $operation = $header->getParentOperation(); |
24 | $input = $header->getParentInput(); |
25 | if (!$operation instanceof Operation || !$input instanceof Input) { |
26 | return; |
27 | } |
28 | |
29 | $serviceMethod = $this->getModel($operation); |
30 | if (!$serviceMethod instanceof Method || $this->isSoapHeaderAlreadyDefined($serviceMethod, $header->getHeaderName())) { |
31 | return; |
32 | } |
33 | |
34 | $serviceMethod |
35 | ->addMeta(self::META_SOAP_HEADERS, [ |
36 | $header->getHeaderRequired(), |
37 | ]) |
38 | ->addMeta(self::META_SOAP_HEADER_NAMES, [ |
39 | $header->getHeaderName(), |
40 | ]) |
41 | ->addMeta(self::META_SOAP_HEADER_TYPES, [ |
42 | $header->getHeaderType(), |
43 | ]) |
44 | ->addMeta(self::META_SOAP_HEADER_NAMESPACES, [ |
45 | $header->getHeaderNamespace(), |
46 | ]) |
47 | ; |
48 | } |
49 | |
50 | protected function parseWsdl(Wsdl $wsdl): void |
51 | { |
52 | foreach ($this->getTags() as $tag) { |
53 | $this->parseHeader($tag); |
54 | } |
55 | } |
56 | |
57 | protected function parsingTag(): string |
58 | { |
59 | return WsdlDocument::TAG_HEADER; |
60 | } |
61 | |
62 | protected function isSoapHeaderAlreadyDefined(Method $method, string $soapHeaderName): bool |
63 | { |
64 | $methodSoapHeaders = $method->getMetaValue(self::META_SOAP_HEADER_NAMES, []); |
65 | |
66 | return in_array($soapHeaderName, $methodSoapHeaders, true); |
67 | } |
68 | } |