Request::setId()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

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