ZipCode   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 44
c 0
b 0
f 0
wmc 4
lcom 1
cbo 0
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getGetParameterValue() 0 8 2
A getGetParameterName() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Marek\OpenWeatherMap\API\Value\Parameter\Input;
6
7
use Marek\OpenWeatherMap\API\Value\Parameter\GetParameterInterface;
8
9
class ZipCode implements GetParameterInterface
10
{
11
    /**
12
     * @var int
13
     */
14
    protected $zip;
15
16
    /**
17
     * @var string|null
18
     */
19
    protected $countryCode;
20
21
    /**
22
     * ZipCode constructor.
23
     *
24
     * @param int $zip
25
     * @param string|null $countryCode
26
     */
27
    public function __construct(int $zip, ?string $countryCode = null)
28
    {
29
        $this->zip = $zip;
30
        $this->countryCode = $countryCode;
31
    }
32
33
    /**
34
     * {@inheritdoc}
35
     */
36
    public function getGetParameterValue(): string
37
    {
38
        if (null === $this->countryCode) {
39
            return (string) $this->zip;
40
        }
41
42
        return (string) $this->zip . ',' . $this->countryCode;
43
    }
44
45
    /**
46
     * {@inheritdoc}
47
     */
48
    public function getGetParameterName(): string
49
    {
50
        return 'zip';
51
    }
52
}
53