CityName   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 60
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 60
c 0
b 0
f 0
wmc 6
lcom 1
cbo 0
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getName() 0 4 1
A getCode() 0 4 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 CityName implements GetParameterInterface
10
{
11
    /**
12
     * @var string
13
     */
14
    protected $name;
15
16
    /**
17
     * @var string|null
18
     */
19
    protected $code;
20
21
    /**
22
     * CityName constructor.
23
     *
24
     * @param string $name
25
     * @param string|null $code
26
     */
27
    public function __construct(string $name, ?string $code = null)
28
    {
29
        $this->name = $name;
30
        $this->code = $code;
31
    }
32
33
    /**
34
     * @return string
35
     */
36
    public function getName(): string
37
    {
38
        return $this->name;
39
    }
40
41
    /**
42
     * @return string|null
43
     */
44
    public function getCode(): ?string
45
    {
46
        return $this->code;
47
    }
48
49
    /**
50
     * {@inheritdoc}
51
     */
52
    public function getGetParameterValue(): string
53
    {
54
        if (null === $this->code) {
55
            return $this->name;
56
        }
57
58
        return $this->name . ',' . (string) $this->code;
59
    }
60
61
    /**
62
     * {@inheritdoc}
63
     */
64
    public function getGetParameterName(): string
65
    {
66
        return 'q';
67
    }
68
}
69