Converter::kelvinToCelsius()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
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
}