Request   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 8
lcom 1
cbo 3
dl 0
loc 57
ccs 20
cts 20
cp 1
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A setConfirm() 0 4 2
A setId() 0 4 1
A setConsumerId() 0 4 1
A search() 0 13 3
1
<?php
2
3
namespace Dgame\Soap\Component;
4
5
use Dgame\Soap\XmlElement;
6
7
/**
8
 * Class Request
9
 * @package Dgame\Soap\Component
10
 */
11
final class Request extends NamedNode
12
{
13
    /**
14
     * Request constructor.
15
     *
16
     * @param BiPROVersion $version
17
     */
18 3
    public function __construct(BiPROVersion $version)
19
    {
20 3
        parent::__construct();
21
22 3
        $this->appendElement($version);
23 3
    }
24
25
    /**
26
     * @param bool $confirm
27
     */
28 2
    public function setConfirm(bool $confirm)
29
    {
30 2
        $this->search('BestaetigeLieferungen')->setValue($confirm ? 'true' : 'false');
31 2
    }
32
33
    /**
34
     * @param int $id
35
     */
36 2
    public function setId(int $id)
0 ignored issues
show
Unused Code introduced by
The parameter $id is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
37
    {
38 2
        $this->search('ID')->setValue(1);
39 2
    }
40
41
    /**
42
     * @param int $id
43
     */
44 2
    public function setConsumerId(int $id)
0 ignored issues
show
Unused Code introduced by
The parameter $id is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
45
    {
46 2
        $this->search('ConsumerID')->setValue(1);
47 2
    }
48
49
    /**
50
     * @param string $name
51
     *
52
     * @return XmlElement
53
     */
54 3
    private function search(string $name): XmlElement
55
    {
56 3
        foreach ($this->getElements() as $element) {
57 3
            if ($element->getName() === $name) {
58 3
                return $element;
59
            }
60
        }
61
62 3
        $element = new XmlElement($name);
63 3
        $this->appendElement($element);
64
65 3
        return $element;
66
    }
67
}