AirPollution   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 34
Duplicated Lines 70.59 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A fetchOzoneData() 12 12 2
A fetchCarbonMonoxideData() 12 12 2

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace Netgen\Bundle\OpenWeatherMapBundle\Core;
4
5
use Netgen\Bundle\OpenWeatherMapBundle\API\OpenWeatherMap\Weather\AirPollutionInterface;
6
7
/**
8
 * Class AirPollution.
9
 */
10
class AirPollution extends Base implements AirPollutionInterface
11
{
12
    /**
13
     * {@inheritdoc}
14
     */
15 View Code Duplication
    public function fetchOzoneData($latitude, $longitude, $datetime = 'current')
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 ($datetime instanceof \DateTime) {
18
            $datetime = $datetime->format('c');
19
        } else {
20
            $datetime = 'current';
21
        }
22
23
        $queryPart = '/co/' . $latitude . ',' . $longitude . '/' . $datetime . '.json?appid=' . $this->apiKey;
24
25
        return $this->getResult(self::BASE_URL, $queryPart);
26
    }
27
28
    /**
29
     * {@inheritdoc}
30
     */
31 View Code Duplication
    public function fetchCarbonMonoxideData($latitude, $longitude, $datetime = 'current')
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...
32
    {
33
        if ($datetime instanceof \DateTime) {
34
            $datetime = $datetime->format('c');
35
        } else {
36
            $datetime = 'current';
37
        }
38
39
        $queryPart = '/co/' . $latitude . ',' . $longitude . '/' . $datetime . '.json?appid=' . $this->apiKey;
40
41
        return $this->getResult(self::BASE_URL, $queryPart);
42
    }
43
}
44