Converter::intToDate()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

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