Passed
Branch reduce-soap-envelope-builder-c... (c98539)
by Rait
02:14
created

Client::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 21
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 11
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 13
nc 2
nop 1
dl 0
loc 21
ccs 11
cts 11
cp 1
crap 2
rs 9.8333
c 1
b 0
f 0
1
<?php
2
3
namespace Raigu\XRoad\SoapEnvelope;
4
5
use Raigu\XRoad\SoapEnvelope\Element\DOMElementInjection;
6
use Raigu\XRoad\SoapEnvelope\Element\FragmentInjection;
7
use Raigu\XRoad\SoapEnvelope\Element\XmlInjectableCollection;
0 ignored issues
show
Bug introduced by
The type Raigu\XRoad\SoapEnvelope...XmlInjectableCollection was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
use Traversable;
9
10
/**
11
 * I am a client who makes X-Road request
12
 *
13
 * I can inject myself into SOAP envelope header
14
 */
15
final class Client extends AggregatedElement
16
{
17
18
    /**
19
     * @param Traversable $reference iterator over data describing client
20
     *        who is making the X-Road request. Iterator must return key value
21
     *        pairs where key represents the tag name and value tag value in
22
     *        SOAP header.
23
     */
24 1
    public function __construct(Traversable $reference)
25
    {
26
        $elements = [
27 1
            new FragmentInjection(
28 1
                'http://schemas.xmlsoap.org/soap/envelope/',
29 1
                'Header',
30
                '<xrd:client xmlns:xrd="http://x-road.eu/xsd/xroad.xsd" ' .
31
                'xmlns:id="http://x-road.eu/xsd/identifiers" ' .
32 1
                'id:objectType="SUBSYSTEM"/>'
33
            ),
34
        ];
35
36 1
        foreach ($reference as $name => $value) {
37 1
            $elements[] = new DOMElementInjection(
38 1
                'http://x-road.eu/xsd/xroad.xsd',
39 1
                'client',
40 1
                new \DOMElement($name, $value, 'http://x-road.eu/xsd/identifiers')
41
            );
42
        }
43
44 1
        parent::__construct(...$elements);
45 1
    }
46
}
47