XMLEncodedUse::generateSoapBody()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 9
ccs 5
cts 5
cp 1
rs 9.9666
c 0
b 0
f 0
cc 1
nc 1
nop 3
crap 1
1
<?php
2
/**
3
 * Copyright (C) 2013-2020
4
 * Piotr Olaszewski <[email protected]>
5
 *
6
 * Permission is hereby granted, free of charge, to any person obtaining a copy
7
 * of this software and associated documentation files (the "Software"), to deal
8
 * in the Software without restriction, including without limitation the rights
9
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
 * copies of the Software, and to permit persons to whom the Software is
11
 * furnished to do so, subject to the following conditions:
12
 *
13
 * The above copyright notice and this permission notice shall be included in
14
 * all copies or substantial portions of the Software.
15
 *
16
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
 * SOFTWARE.
23
 */
24
namespace WSDL\XML\XMLUse;
25
26
use DOMDocument;
27
use DOMElement;
28
use WSDL\Builder\Parameter;
29
use WSDL\XML\XMLAttributeHelper;
30
31
/**
32
 * XMLEncodedUse
33
 *
34
 * @author Piotr Olaszewski <[email protected]>
35
 */
36
class XMLEncodedUse implements XMLUse
37
{
38
    public function generateSoapBody(DOMDocument $DOMDocument, string $targetNamespace, string $soapVersion): DOMElement
39
    {
40 1
        return XMLAttributeHelper::forDOM($DOMDocument)
41
            ->createElementWithAttributes($soapVersion . ':body', [
42 1
                'use' => 'encoded',
43 1
                'namespace' => $targetNamespace,
44 1
                'encodingStyle' => 'http://schemas.xmlsoap.org/soap/encoding/'
45 1
            ]);
46
    }
47 1
48 1
    public function generateSoapHeaderIfNeeded(DOMDocument $DOMDocument, string $targetNamespace, string $soapVersion, string $soapHeaderMessage = '', Parameter $header = null): ?DOMElement
49
    {
50
        if ($header) {
51
            return XMLAttributeHelper::forDOM($DOMDocument)
52
                ->createElementWithAttributes($soapVersion . ':header', [
53
                    'use' => 'encoded',
54 2
                    'namespace' => $targetNamespace,
55
                    'encodingStyle' => 'http://schemas.xmlsoap.org/soap/encoding/',
56 2
                    'part' => $header->getNode()->getSanitizedName(),
57 1
                    'message' => $soapHeaderMessage
58 1
                ]);
59 1
        }
60 1
61 1
        return null;
62 1
    }
63
}
64