Completed
Push — master ( 126b63...733cbc )
by Randy
04:39
created

Request   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 8
lcom 1
cbo 2
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
use Exception;
7
8
/**
9
 * Class Request
10
 * @package Dgame\Soap\Component
11
 */
12
final class Request extends NamedNode
13
{
14
    /**
15
     * Request constructor.
16
     *
17
     * @param BiPROVersion $version
18
     */
19 3
    public function __construct(BiPROVersion $version)
20
    {
21 3
        parent::__construct();
22
23 3
        $this->appendElement($version);
24 3
    }
25
26
    /**
27
     * @param bool $confirm
28
     */
29 2
    public function setConfirm(bool $confirm)
30
    {
31 2
        $this->search('BestaetigeLieferungen')->setValue($confirm ? 'true' : 'false');
32 2
    }
33
34
    /**
35
     * @param int $id
36
     */
37 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...
38
    {
39 2
        $this->search('ID')->setValue(1);
40 2
    }
41
42
    /**
43
     * @param int $id
44
     */
45 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...
46
    {
47 2
        $this->search('ConsumerID')->setValue(1);
48 2
    }
49
50
    /**
51
     * @param string $name
52
     *
53
     * @return XmlElement
54
     */
55 3
    private function search(string $name): XmlElement
56
    {
57 3
        foreach ($this->getElements() as $element) {
58 3
            if ($element->getName() === $name) {
59 3
                return $element;
60
            }
61
        }
62
63 3
        $element = new XmlElement($name);
64 3
        $this->appendElement($element);
65
66 3
        return $element;
67
    }
68
}