Completed
Branch 2.0.0-dev (4220a4)
by Jeroen
03:47
created

Telephone::setValue()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace JeroenDesloovere\VCard\Property;
6
7
use JeroenDesloovere\VCard\Formatter\Property\NodeFormatterInterface;
8
use JeroenDesloovere\VCard\Formatter\Property\TelephoneFormatter;
9
use JeroenDesloovere\VCard\Parser\Property\NodeParserInterface;
10
use JeroenDesloovere\VCard\Parser\Property\TelephoneParser;
11
use JeroenDesloovere\VCard\Property\Parameter\Type;
12
use JeroenDesloovere\VCard\Property\Parameter\Value;
13
14
final class Telephone implements PropertyInterface, NodeInterface
15
{
16
    /** @var string */
17
    protected $telephoneNumber;
18
19
    /** @var Type */
20
    private $type;
21
22
    /** @var Value */
23
    private $value;
24
25
    public function __construct(string $telephoneNumber, Type $type = null, Value $value = null)
26
    {
27
        $this->telephoneNumber = str_replace(' ', '-', $telephoneNumber);
28
        $this->type = $type ?? Type::home();
29
        $this->value = $value ?? Value::uri();
30
    }
31
32
    public function __toString(): string
33
    {
34
        return $this->telephoneNumber;
35
    }
36
37
    public function getFormatter(): NodeFormatterInterface
38
    {
39
        return new TelephoneFormatter($this);
40
    }
41
42
    public static function getNode(): string
43
    {
44
        return 'TEL';
45
    }
46
47
    public function getTelephoneNumber(): string
48
    {
49
        return $this->telephoneNumber;
50
    }
51
52
    public static function getParser(): NodeParserInterface
53
    {
54
        return new TelephoneParser();
55
    }
56
57
    public function isAllowedMultipleTimes(): bool
58
    {
59
        return true;
60
    }
61
62
    public function getType(): Type
63
    {
64
        return $this->type;
65
    }
66
67
    public function setType(Type $type)
68
    {
69
        $this->type = $type;
70
    }
71
72
    public function getValue(): Value
73
    {
74
        return $this->value;
75
    }
76
77
    public function setValue(Value $value)
78
    {
79
        $this->value = $value;
80
    }
81
}
82