Completed
Push — master ( b22c70...b1922d )
by Dariusz
01:37
created

Converter   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 31
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 31
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
    public static function kelvinToCelsius($temp)
8
    {
9
        return (float) $temp - 273.15;
10
    }
11
12
    public static function celsiusToKelvin($temp)
13
    {
14
        return (float) $temp + 273.15;
15
    }
16
17
    public static function kelvinToFahrenheit($temp)
18
    {
19
        return (float) $temp * 9/5 - 459.67;
20
    }
21
22
    public static function fahrenheitToKelvin($temp)
23
    {
24
        return ((float) $temp + 459.67) * 5/9;
25
    }
26
27
    public static function intToDate($int, $format = null)
28
    {
29
        if($format) {
30
            return date($format, $int);
31
        }
32
33
        return date("Y-m-d H:i:s", $int);
34
    }
35
}