Processor   A
last analyzed

Complexity

Total Complexity 11

Size/Duplication

Total Lines 99
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 39
dl 0
loc 99
rs 10
c 0
b 0
f 0
wmc 11

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getHatsuikuTeishiOndos() 0 6 1
A getHatsuikuZeroTens() 0 6 1
A getYukoSekisanOndos() 0 6 1
A toChakabunaiOndo() 0 22 5
A toHiatariYukoOndo() 0 17 3
1
<?php
2
3
namespace KuwashiroBuster\Processor;
4
5
use KuwashiroBuster\Constraints\CoverType;
6
use KuwashiroBuster\Constraints\Generation;
7
8
class Processor implements ProcessorInterface
9
{
10
    /**
11
     * 世代ごとの有効積算温度を返す
12
     *
13
     * @return array
14
     */
15
    public function getYukoSekisanOndos()
16
    {
17
        return array(
18
            Generation::GENERATION_1 => 287,
19
            Generation::GENERATION_2 => 688,
20
            Generation::GENERATION_3 => 688
21
        );
22
    }
23
24
    /**
25
     * 世代ごとの発育ゼロ点を返す
26
     *
27
     * @return array
28
     */
29
    public function getHatsuikuZeroTens()
30
    {
31
        return array(
32
            Generation::GENERATION_1 => 10.5,
33
            Generation::GENERATION_2 => 10.8,
34
            Generation::GENERATION_3 => 10.8,
35
        );
36
    }
37
38
    /**
39
     * 世代ごとの発育停止温度を返す
40
     *
41
     * @return array
42
     */
43
    public function getHatsuikuTeishiOndos()
44
    {
45
        return array(
46
            Generation::GENERATION_1 => INF,
47
            Generation::GENERATION_2 => 30,
48
            Generation::GENERATION_3 => 30,
49
        );
50
    }
51
52
    /**
53
     * 気温を茶株内温度に変換する
54
     *
55
     * @param $temperature
56
     * @param $coverType
57
     * @return float|int
58
     */
59
    public function toChakabunaiOndo($temperature, $coverType)
60
    {
61
        $y = 0;
62
63
        switch ($coverType) {
64
            case CoverType::ROTEN:
65
                $y = 0.9608 * $temperature - 0.2239;
66
                break;
67
            case CoverType::HITIE_HIFUKU:
68
                $y = 0.8124 * $temperature + 1.2012;
69
                break;
70
            case CoverType::FUTAE_HIFUKU:
71
                $y = 0.7437 * $temperature + 2.1705;
72
                break;
73
            case CoverType::BANGARI:
74
                $y = 1.1749 * $temperature - 3.1831;
75
                break;
76
            default:
77
                break;
78
        }
79
80
        return $y;
81
    }
82
83
    /**
84
     * 茶株内温度を日当たり有効温度に変換する
85
     *
86
     * @param $chakabunaiOndo
87
     * @param $generation
88
     * @return float|int
89
     */
90
    public function toHiatariYukoOndo($chakabunaiOndo, $generation)
91
    {
92
        $hatsuikuTeishiOndos = $this->getHatsuikuTeishiOndos();
93
        $hatsuikuZeroTens = $this->getHatsuikuZeroTens();
94
95
        $hatsuikuTeishiOndo = $hatsuikuTeishiOndos[$generation];
96
        if ($chakabunaiOndo >= $hatsuikuTeishiOndo) {
97
            return 0;
98
        }
99
100
        $hiatariYukoOndo = ($chakabunaiOndo - $hatsuikuZeroTens[$generation]) / 24;
101
102
        if ($hiatariYukoOndo > 0) {
103
            return $hiatariYukoOndo;
104
        }
105
106
        return 0;
107
    }
108
}