Contact::getType()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 1
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
c 1
b 0
f 1
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
/**
4
 * This file is part of the ddd-common.
5
 *
6
 * Copyright 2021 Evgenii Dudal <[email protected]>.
7
 *
8
 * This source file is subject to the MIT license that is bundled
9
 * with this source code in the file LICENSE.
10
 * @package ddd-common
11
 */
12
13
namespace RobotE13\DDD\Entities\Collection\Contact;
14
15
/**
16
 * Description of Contact
17
 *
18
 * @author Evgenii Dudal <[email protected]>
19
 */
20
class Contact
21
{
22
23
    /**
24
     * Contact type.
25
     * Emali, skype, telegram e t.c.
26
     * @var string
27
     */
28
    private $type;
29
30
    /**
31
     * @var string
32
     */
33
    private $value;
34
35 4
    public function __construct(string $type, string $value)
36
    {
37 4
        $this->type = strtolower($type);
38 4
        $this->value = $value;
39 4
    }
40
41 2
    public function getType(): string
42
    {
43 2
        return $this->type;
44
    }
45
46 2
    public function getValue(): string
47
    {
48 2
        return $this->value;
49
    }
50
51
    public function isEqualTo(self $contact)
52
    {
53
        return $this->type === $contact->getType() && $this->value === $contact->getValue();
54
    }
55
56
}
57