Contact::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 5
c 1
b 0
f 0
nc 1
nop 5
dl 0
loc 12
ccs 6
cts 6
cp 1
crap 1
rs 10
1
<?php
2
3
namespace ApiChef\NotifyLK;
4
5
class Contact
6
{
7
    /** @var string */
8
    private $firstName;
9
10
    /** @var string|null */
11
    private $lastName;
12
13
    /** @var string|null */
14
    private $email;
15
16
    /** @var string|null */
17
    private $address;
18
19
    /** @var string|null */
20
    private $group;
21
22 3
    public function __construct(
23
        string $firstName,
24
        string $lastName = null,
25
        string $email = null,
26
        string $address = null,
27
        string $group = null
28
    ) {
29 3
        $this->firstName = $firstName;
30 3
        $this->lastName = $lastName;
31 3
        $this->email = $email;
32 3
        $this->address = $address;
33 3
        $this->group = $group;
34 3
    }
35
36 3
    public function toArray(): array
37
    {
38 3
        $data = ['contact_fname' => $this->firstName];
39
40 3
        if ($this->lastName) {
41 3
            $data['contact_lname'] = $this->lastName;
42
        }
43
44 3
        if ($this->email) {
45 3
            $data['contact_email'] = $this->email;
46
        }
47
48 3
        if ($this->address) {
49 3
            $data['contact_address'] = $this->address;
50
        }
51
52 3
        if ($this->group) {
53 3
            $data['contact_group'] = $this->group;
54
        }
55
56 3
        return $data;
57
    }
58
}
59