Weather::fetchWeatherDataByZipCode()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 12

Duplication

Lines 12
Ratio 100 %

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 2
dl 12
loc 12
rs 9.8666
c 0
b 0
f 0
1
<?php
2
3
namespace Netgen\Bundle\OpenWeatherMapBundle\Core;
4
5
use Netgen\Bundle\OpenWeatherMapBundle\API\OpenWeatherMap\Weather\WeatherInterface;
6
7
/**
8
 * Class Weather.
9
 */
10
class Weather extends WeatherBase implements WeatherInterface
11
{
12
    /**
13
     * {@inheritdoc}
14
     */
15 View Code Duplication
    public function fetchWeatherDataByCityName($cityName, $countryCode = '')
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
16
    {
17
        if (empty($countryCode)) {
18
            $queryPart = '/weather?q=' . $cityName;
19
        } else {
20
            $queryPart = '/weather?q=' . $cityName . ',' . $countryCode;
21
        }
22
23
        $queryPart = $queryPart . $this->getParams();
24
25
        return $this->getResult(self::BASE_URL, $queryPart);
26
    }
27
28
    /**
29
     * {@inheritdoc}
30
     */
31
    public function fetchWeatherDataByCityId($cityId)
32
    {
33
        $queryPart = '/weather?id=' . $cityId . $this->getParams();
34
35
        return $this->getResult(self::BASE_URL, $queryPart);
36
    }
37
38
    /**
39
     * {@inheritdoc}
40
     */
41
    public function fetchWeatherDataByGeographicCoordinates($latitude, $longitude)
42
    {
43
        $queryPart = '/weather?lat=' . $latitude . '&lon=' . $longitude . $this->getParams();
44
45
        return $this->getResult(self::BASE_URL, $queryPart);
46
    }
47
48
    /**
49
     * {@inheritdoc}
50
     */
51 View Code Duplication
    public function fetchWeatherDataByZipCode($zipCode, $countryCode = '')
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
52
    {
53
        if (empty($countryCode)) {
54
            $queryPart = '/weather?zip=' . $zipCode;
55
        } else {
56
            $queryPart = '/weather?zip=' . $zipCode . ',' . $countryCode;
57
        }
58
59
        $queryPart = $queryPart . $this->getParams();
60
61
        return $this->getResult(self::BASE_URL, $queryPart);
62
    }
63
64
    /**
65
     * {@inheritdoc}
66
     */
67
    public function fetchWeatherDataForCitiesWithinRectangleZone(array $boundingBox, $cluster = 'yes')
68
    {
69
        $queryPart = '/box/city?bbox=' . implode(',', $boundingBox) . '&cluster=' . $cluster . $this->getParams();
70
71
        return $this->getResult(self::BASE_URL, $queryPart);
72
    }
73
74
    /**
75
     * {@inheritdoc}
76
     */
77
    public function fetchWeatherDataForCitiesInCycle($latitude, $longitude, $cluster = 'yes', $numberOfCities = 10)
78
    {
79
        $queryPart = '/find?lat=' . $latitude
80
            . '&lon=' . $longitude
81
            . '&cluster=' . $cluster
82
            . '&cnt=' . $numberOfCities . $this->getParams();
83
84
        return $this->getResult(self::BASE_URL, $queryPart);
85
    }
86
87
    /**
88
     * {@inheritdoc}
89
     */
90
    public function fetchWeatherDataForSeveralCityIds(array $cities)
91
    {
92
        $queryPart = '/group?id=' . implode(',', $cities) . $this->getParams();
93
94
        return $this->getResult(self::BASE_URL, $queryPart);
95
    }
96
}
97