Converter   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

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

5 Methods

Rating   Name   Duplication   Size   Complexity  
A kelvinToCelsius() 0 4 1
A celsiusToKelvin() 0 4 1
A kelvinToFahrenheit() 0 4 1
A fahrenheitToKelvin() 0 4 1
A intToDate() 0 8 2
1
<?php
2
3
namespace Dwr\OpenWeather\Converter;
4
5
class Converter
6
{
7
    const ROUND_FLOAT = 2;
8
9
    public static function kelvinToCelsius($temp)
10
    {
11
        return round((float) $temp - 273.15, self::ROUND_FLOAT);
12
    }
13
14
    public static function celsiusToKelvin($temp)
15
    {
16
        return round((float) $temp + 273.15, self::ROUND_FLOAT);
17
    }
18
19
    public static function kelvinToFahrenheit($temp)
20
    {
21
        return round((float) $temp * 9/5 - 459.67, self::ROUND_FLOAT);
22
    }
23
24
    public static function fahrenheitToKelvin($temp)
25
    {
26
        return round(((float) $temp + 459.67) * 5/9, self::ROUND_FLOAT);
27
    }
28
29
    public static function intToDate($int, $format = null)
30
    {
31
        if ($format) {
32
            return date($format, $int);
33
        }
34
35
        return date("Y-m-d H:i:s", $int);
36
    }
37
}