Completed
Pull Request — new-version (#111)
by Tom
02:24
created

Gender   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 50
rs 10
c 0
b 0
f 0
wmc 9

7 Methods

Rating   Name   Duplication   Size   Complexity  
A getNode() 0 3 1
A isAllowedMultipleTimes() 0 3 1
A getNote() 0 3 1
A getParser() 0 3 1
A getGender() 0 3 1
A getFormatter() 0 3 1
A __construct() 0 8 3
1
<?php
2
3
namespace JeroenDesloovere\VCard\Property;
4
5
use JeroenDesloovere\VCard\Exception\PropertyException;
6
use JeroenDesloovere\VCard\Formatter\Property\GenderFormatter;
7
use JeroenDesloovere\VCard\Formatter\Property\NodeFormatterInterface;
8
use JeroenDesloovere\VCard\Parser\Property\GenderParser;
9
use JeroenDesloovere\VCard\Parser\Property\NodeParserInterface;
10
use JeroenDesloovere\VCard\Property\Parameter\GenderType;
11
12
final class Gender implements PropertyInterface, NodeInterface
13
{
14
    /**
15
     * @var GenderType
16
     */
17
    private $gender;
18
19
    /**
20
     * @var null|string
21
     */
22
    private $note;
23
24
    public function __construct(?GenderType $gender = null, ?string $note = null)
25
    {
26
        if ($gender === null && $note === null) {
27
            throw PropertyException::forEmptyProperty();
28
        }
29
30
        $this->gender = $gender ?? GenderType::empty();
31
        $this->note = $note;
32
    }
33
34
    public function getFormatter(): NodeFormatterInterface
35
    {
36
        return new GenderFormatter($this);
37
    }
38
39
    public static function getNode(): string
40
    {
41
        return 'GENDER';
42
    }
43
44
    public static function getParser(): NodeParserInterface
45
    {
46
        return new GenderParser();
47
    }
48
49
    public function isAllowedMultipleTimes(): bool
50
    {
51
        return false;
52
    }
53
54
    public function getGender(): GenderType
55
    {
56
        return $this->gender;
57
    }
58
59
    public function getNote(): ?string
60
    {
61
        return $this->note;
62
    }
63
}
64