Code Duplication    Length = 9-12 lines in 14 locations

lib/Core/Weather/DailyForecast.php 4 locations

@@ 19-28 (lines=10) @@
16
    /**
17
     * @inheritDoc
18
     */
19
    public function fetchForecastByCityName(CityName $cityName, DaysCount $numberOfDays)
20
    {
21
        $params = $this->factory->buildBag(self::BASE_URL);
22
        $params->setParameter($cityName);
23
        $params->setParameter($numberOfDays);
24
25
        $response = $this->getResult($this->factory->build($params));
26
27
        return $this->hydrator->hydrate($response, new AggregatedDailyForecast());
28
    }
29
30
    /**
31
     * @inheritDoc
@@ 33-42 (lines=10) @@
30
    /**
31
     * @inheritDoc
32
     */
33
    public function fetchForecastByCityId(CityId $cityId, DaysCount $numberOfDays)
34
    {
35
        $params = $this->factory->buildBag(self::BASE_URL);
36
        $params->setParameter($cityId);
37
        $params->setParameter($numberOfDays);
38
39
        $response = $this->getResult($this->factory->build($params));
40
41
        return $this->hydrator->hydrate($response, new AggregatedDailyForecast());
42
    }
43
44
    /**
45
     * @inheritDoc
@@ 47-56 (lines=10) @@
44
    /**
45
     * @inheritDoc
46
     */
47
    public function fetchForecastByZipCode(ZipCode $zipCode, DaysCount $numberOfDays)
48
    {
49
        $params = $this->factory->buildBag(self::BASE_URL);
50
        $params->setParameter($zipCode);
51
        $params->setParameter($numberOfDays);
52
53
        $response = $this->getResult($this->factory->build($params));
54
55
        return $this->hydrator->hydrate($response, new AggregatedDailyForecast());
56
    }
57
58
    /**
59
     * @inheritDoc
@@ 61-71 (lines=11) @@
58
    /**
59
     * @inheritDoc
60
     */
61
    public function fetchForecastByCityGeographicCoordinates(Latitude $latitude, Longitude $longitude, DaysCount $numberOfDays)
62
    {
63
        $params = $this->factory->buildBag(self::BASE_URL);
64
        $params->setParameter($latitude);
65
        $params->setParameter($longitude);
66
        $params->setParameter($numberOfDays);
67
68
        $response = $this->getResult($this->factory->build($params));
69
70
        return $this->hydrator->hydrate($response, new AggregatedDailyForecast());
71
    }
72
}
73

lib/Core/Weather/HourForecast.php 4 locations

@@ 18-26 (lines=9) @@
15
    /**
16
     * @inheritDoc
17
     */
18
    public function fetchForecastByCityName(CityName $cityName)
19
    {
20
        $params = $this->factory->buildBag(self::BASE_URL);
21
        $params->setParameter($cityName);
22
23
        $response = $this->getResult($this->factory->build($params));
24
25
        return $this->hydrator->hydrate($response, new AggregatedHourForecast());
26
    }
27
28
    /**
29
     * @inheritDoc
@@ 31-39 (lines=9) @@
28
    /**
29
     * @inheritDoc
30
     */
31
    public function fetchForecastByCityId(CityId $cityId)
32
    {
33
        $params = $this->factory->buildBag(self::BASE_URL);
34
        $params->setParameter($cityId);
35
36
        $response = $this->getResult($this->factory->build($params));
37
38
        return $this->hydrator->hydrate($response, new AggregatedHourForecast());
39
    }
40
41
    /**
42
     * @inheritDoc
@@ 44-52 (lines=9) @@
41
    /**
42
     * @inheritDoc
43
     */
44
    public function fetchForecastByZipCode(ZipCode $zipCode)
45
    {
46
        $params = $this->factory->buildBag(self::BASE_URL);
47
        $params->setParameter($zipCode);
48
49
        $response = $this->getResult($this->factory->build($params));
50
51
        return $this->hydrator->hydrate($response, new AggregatedHourForecast());
52
    }
53
54
    /**
55
     * @inheritDoc
@@ 57-66 (lines=10) @@
54
    /**
55
     * @inheritDoc
56
     */
57
    public function fetchForecastByCityGeographicCoordinates(Latitude $latitude, Longitude $longitude)
58
    {
59
        $params = $this->factory->buildBag(self::BASE_URL);
60
        $params->setParameter($latitude);
61
        $params->setParameter($longitude);
62
63
        $response = $this->getResult($this->factory->build($params));
64
65
        return $this->hydrator->hydrate($response, new AggregatedHourForecast());
66
    }
67
}
68

lib/Core/Weather/UltravioletIndex.php 1 location

@@ 15-24 (lines=10) @@
12
    /**
13
     * @inheritDoc
14
     */
15
    public function fetchUltravioletIndex(GeographicCoordinates $coordinates, DateTime $datetime)
16
    {
17
        $params = $this->factory->buildBag(self::BASE_URL);
18
        $params->setParameter($coordinates);
19
        $params->setParameter($datetime);
20
21
        $result = $this->getResult($this->factory->build($params));
22
23
        return $this->hydrator->hydrate($result, new UltravioletIndexResponse());
24
    }
25
}
26

lib/Core/Weather/Weather.php 5 locations

@@ 36-44 (lines=9) @@
33
    /**
34
     * @inheritDoc
35
     */
36
    public function byCityId(CityId $cityId)
37
    {
38
        $params = $this->factory->buildBag(self::URL_WEATHER);
39
        $params->setParameter($cityId);
40
41
        $response = $this->getResult($this->factory->build($params));
42
43
        return $this->hydrator->hydrate($response, new WeatherResponse());
44
    }
45
46
    /**
47
     * @inheritDoc
@@ 49-58 (lines=10) @@
46
    /**
47
     * @inheritDoc
48
     */
49
    public function byGeographicCoordinates(Latitude $latitude, Longitude $longitude)
50
    {
51
        $params = $this->factory->buildBag(self::URL_WEATHER);
52
        $params->setParameter($latitude);
53
        $params->setParameter($longitude);
54
55
        $response = $this->getResult($this->factory->build($params));
56
57
        return $this->hydrator->hydrate($response, new WeatherResponse());
58
    }
59
60
    /**
61
     * @inheritDoc
@@ 63-71 (lines=9) @@
60
    /**
61
     * @inheritDoc
62
     */
63
    public function byZipCode(ZipCode $zipCode)
64
    {
65
        $params = $this->factory->buildBag(self::URL_WEATHER);
66
        $params->setParameter($zipCode);
67
68
        $response = $this->getResult($this->factory->build($params));
69
70
        return $this->hydrator->hydrate($response, new WeatherResponse());
71
    }
72
73
    /**
74
     * @inheritDoc
@@ 90-101 (lines=12) @@
87
    /**
88
     * @inheritDoc
89
     */
90
    public function inCycle(Latitude $latitude, Longitude $longitude, Cluster $cluster, CityCount $cnt)
91
    {
92
        $params = $this->factory->buildBag(self::URL_CYCLE);
93
        $params->setParameter($latitude);
94
        $params->setParameter($longitude);
95
        $params->setParameter($cluster);
96
        $params->setParameter($cnt);
97
98
        $response = $this->getResult($this->factory->build($params));
99
100
        return $this->hydrator->hydrate($response, new AggregatedWeather());
101
    }
102
103
    /**
104
     * @inheritDoc
@@ 106-114 (lines=9) @@
103
    /**
104
     * @inheritDoc
105
     */
106
    public function severalCityIds(CityIds $cityIds)
107
    {
108
        $params = $this->factory->buildBag(self::URL_CITIES);
109
        $params->setParameter($cityIds);
110
111
        $response = $this->getResult($this->factory->build($params));
112
113
        return $this->hydrator->hydrate($response, new AggregatedWeather());
114
    }
115
}
116