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

Request::setConfirm()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 2
eloc 2
nc 1
nop 1
crap 2
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
}