CityIds::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 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 CityIds implements GetParameterInterface
10
{
11
    /**
12
     * @var CityId[]
13
     */
14
    protected $cityIds;
15
16
    /**
17
     * CityIds constructor.
18
     *
19
     * @param CityId[] $cityIds
20
     */
21
    public function __construct(array $cityIds = [])
22
    {
23
        $this->cityIds = $cityIds;
24
    }
25
26
    /**
27
     * {@inheritdoc}
28
     */
29
    public function getGetParameterValue(): string
30
    {
31
        $values = [];
32
        foreach ($this->cityIds as $cityId) {
33
            $values[] = $cityId->getCityId();
34
        }
35
36
        return implode(',', $values);
37
    }
38
39
    /**
40
     * {@inheritdoc}
41
     */
42
    public function getGetParameterName(): string
43
    {
44
        return 'id';
45
    }
46
}
47