PostalAddress::getPostalCode()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * This file is part of byrokrat\giroapp.
5
 *
6
 * byrokrat\giroapp is free software: you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License as published
8
 * by the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * byrokrat\giroapp is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with byrokrat\giroapp. If not, see <http://www.gnu.org/licenses/>.
18
 *
19
 * Copyright 2016-21 Hannes Forsgård
20
 */
21
22
declare(strict_types=1);
23
24
namespace byrokrat\giroapp\Domain;
25
26
/**
27
 * Models a swedish postal address
28
 */
29
class PostalAddress
30
{
31
    /**
32
     * @var string
33
     */
34
    private $line1;
35
36
    /**
37
     * @var string
38
     */
39
    private $line2;
40
41
    /**
42
     * @var string
43
     */
44
    private $line3;
45
46
    /**
47
     * @var string
48
     */
49
    private $postalCode;
50
51
    /**
52
     * @var string
53
     */
54
    private $postalCity;
55
56
    public function __construct(
57
        string $line1 = '',
58
        string $line2 = '',
59
        string $line3 = '',
60
        string $postalCode = '',
61
        string $postalCity = ''
62
    ) {
63
        $this->line1 = $line1;
64
        $this->line2 = $line2;
65
        $this->line3 = $line3;
66
        $this->postalCode = $postalCode;
67
        $this->postalCity = $postalCity;
68
    }
69
70
    public function getLine1(): string
71
    {
72
        return $this->line1;
73
    }
74
75
    public function getLine2(): string
76
    {
77
        return $this->line2;
78
    }
79
80
    public function getLine3(): string
81
    {
82
        return $this->line3;
83
    }
84
85
    public function getPostalCode(): string
86
    {
87
        return $this->postalCode;
88
    }
89
90
    public function getPostalCity(): string
91
    {
92
        return $this->postalCity;
93
    }
94
95
    public function __toString(): string
96
    {
97
        return implode(PHP_EOL, array_filter([
98
            $this->getLine1(),
99
            $this->getLine2(),
100
            $this->getLine3(),
101
            "{$this->getPostalCode()} {$this->getPostalCity()}"
102
        ]));
103
    }
104
}
105