Characteristic::getDisplayValue()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 2
1
<?php
2
3
namespace Bpost\BpostApiClient\Bpost\ProductConfiguration;
4
5
use SimpleXMLElement;
6
7
/**
8
 * Class Characteristic
9
 * @package Bpost\BpostApiClient\Bpost\ProductConfiguration
10
 */
11
class Characteristic
12
{
13
    /** @var  string */
14
    private $displayValue;
15
    /** @var  int */
16
    private $value;
17
    /** @var  string */
18
    private $name;
19
20
    /**
21
     * @param SimpleXMLElement $xml
22
     *
23
     * @return Characteristic
24
     */
25
    public static function createFromXML(SimpleXMLElement $xml)
26
    {
27
        /*
28
        <characteristic displayValue="Basic (0-500 EUR)" value="1" name="Insurance range code"/>
29
        */
30
        $attributes = $xml->attributes();
31
32
        $option = new self();
33
        $option->setDisplayValue($attributes['displayValue']);
34
        $option->setValue($attributes['value']);
35
        $option->setName($attributes['name']);
36
37
        return $option;
38
    }
39
40
    /**
41
     * @return string
42
     */
43
    public function getDisplayValue()
44
    {
45
        return $this->displayValue;
46
    }
47
48
    /**
49
     * @param string $displayValue
50
     */
51
    public function setDisplayValue($displayValue)
52
    {
53
        $this->displayValue = (string) $displayValue;
54
    }
55
56
    /**
57
     * @return int
58
     */
59
    public function getValue()
60
    {
61
        return $this->value;
62
    }
63
64
    /**
65
     * @param int $value
66
     */
67
    public function setValue($value)
68
    {
69
        $this->value = (int) $value;
70
    }
71
72
    /**
73
     * @return string
74
     */
75
    public function getName()
76
    {
77
        return $this->name;
78
    }
79
80
    /**
81
     * @param string $name
82
     */
83
    public function setName($name)
84
    {
85
        $this->name = (string) $name;
86
    }
87
88
}
89