HeatIndex   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 70
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
c 1
b 0
f 0
lcom 1
cbo 0
dl 0
loc 70
ccs 16
cts 16
cp 1
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getTemp() 0 4 1
A setTemp() 0 5 1
A getDewPoint() 0 4 1
A setDewPoint() 0 5 1
A calc() 0 9 1
1
<?php
2
/**
3
 *
4
 * PHP version 5.5
5
 *
6
 * @package Forecast\Models
7
 * @author  Sergey V.Kuzin <[email protected]>
8
 * @license MIT
9
 */
10
declare(strict_types=1);
11
namespace Forecast\Models;
12
13
14
class HeatIndex
15
{
16
    /**
17
     * Температура в целсиях
18
     * @var float
19
     */
20
    protected $temp = null;
21
22
    /**
23
     * Коофецент влажность 0 < $humidity < 1
24
     * @var float
25
     */
26
    protected $dewPoint = null;
27
28
    /**
29
     * @return float
30
     */
31 2
    public function getTemp(): float
32
    {
33 2
        return $this->temp;
34
    }
35
36
    /**
37
     * @param float $temp
38
     */
39 2
    public function setTemp(float $temp): self
40
    {
41 2
        $this->temp = $temp;
42 2
        return $this;
43
    }
44
45
    /**
46
     * @return float
47
     */
48 2
    public function getDewPoint(): float
49
    {
50 2
        return $this->dewPoint;
51
    }
52
53
    /**
54
     * @param float $dewPoint
55
     */
56 2
    public function setDewPoint(float $dewPoint): self
57
    {
58 2
        $this->dewPoint = $dewPoint;
59 2
        return $this;
60
    }
61
62
    /**
63
     * 		<table border="1">
64
    <tr><td><strong>Humidex Range</strong></td><td><strong>Degree of Comfort</strong></td></tr>
65
    <tr><td>20-29</td><td style="color: #4CD900;">Comfortable</td></tr>
66
    <tr><td>30-39</td><td style="color: #FFD800;">Some Discomfort</td></tr>
67
    <tr><td>40-45</td><td style="color: #FF6A00;">Great Discomfort</td></tr>
68
    <tr><td>>45</td><td style="color: #FF0000;">Dangerous</td></tr>
69
    </table>
70
     *
71
     * @return float
72
     */
73 1
    public function calc(): float
74
    {
75 1
        $dewpointK = $this->getDewPoint() + 273.15;
76 1
        $e = 6.11 * exp(5417.7530 * ((1 / 273.16) - (1 / $dewpointK)));
77 1
        $h = (0.5555) * ($e - 10.0);
78 1
        $humidex = $this->getTemp() + $h;
79
80 1
        return $humidex;
81
    }
82
83
}
84