GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 6fcb7a...fcde01 )
by t
06:59 queued 04:42
created

RMAT::roman()   B

Complexity

Conditions 8
Paths 10

Size

Total Lines 30
Code Lines 20

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 72

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 8
eloc 20
c 1
b 0
f 0
nc 10
nop 1
dl 0
loc 30
ccs 0
cts 14
cp 0
crap 72
rs 8.4444
1
<?php
2
/**
3
 * Trait MathAndTrigonometry-R
4
 *
5
 * @link https://www.icy2003.com/
6
 * @author icy2003 <[email protected]>
7
 * @copyright Copyright (c) 2017, icy2003
8
 */
9
namespace icy2003\php\icomponents\excel\mathAndTrigonometry;
10
11
/**
12
 * MathAndTrigonometry-R
13
 */
14
trait RMAT
15
{
16
    /**
17
     * 将度数转换为弧度
18
     *
19
     * @param double $angle 必需。 要转换的以度数表示的角度
20
     *
21
     * @return double
22
     */
23
    public static function radians($angle)
24
    {
25
        return deg2rad($angle);
26
    }
27
28
    /**
29
     * 返回了一个大于等于 0 且小于 1 的平均分布的随机实数
30
     *
31
     * @return double
32
     */
33
    public static function rand()
34
    {
35
        return mt_rand(0, (int) self::power(10, 10)) / self::power(10, 10);
36
    }
37
38
    /**
39
     * 函数返回一组随机数字。 可指定要填充的行数和列数,最小值和最大值,以及是否返回整数或小数值
40
     *
41
     * @param integer $row 要返回的行数
42
     * @param integer $col 要返回的列数
43
     * @param integer $min 想返回的最小数值
44
     * @param integer $max 想返回的最大数值
45
     * @param boolean $isInt 返回整数或小数
46
     *
47
     * @return array
48
     */
49
    public static function randarray($row = 1, $col = 1, $min = 0, $max = null, $isInt = false)
50
    {
51
        null === $max && $max = (int) pow(10, 10);
52
        $array = [];
53
        for ($i = 0; $i < $row; $i++) {
54
            for ($j = 0; $j < $col; $j++) {
55
                $array[$i][$j] = mt_rand($min, $max) + ($isInt ? 0 : mt_rand(0, (int) pow(10, 10)) / pow(10, 10));
56
            }
57
        }
58
        return $array;
59
    }
60
61
    /**
62
     * 返回位于两个指定数之间的一个随机整数
63
     *
64
     * @param integer $bottom 必需。 RANDBETWEEN 将返回的最小整数
65
     * @param integer $top 必需。 RANDBETWEEN 将返回的最大整数
66
     *
67
     * @return integer
68
     */
69
    public static function randbetween($bottom, $top)
70
    {
71
        return mt_rand($bottom, $top);
72
    }
73
74
    /**
75
     * 将阿拉伯数字转换为文字形式的罗马数字
76
     *
77
     * - 注意:不支持简明版
78
     *
79
     * @param integer $number
80
     *
81
     * @return string|false
82
     */
83
    public static function roman($number)
84
    {
85
        if (!is_numeric($number) || $number > 3999 || $number <= 0) {
0 ignored issues
show
introduced by
The condition is_numeric($number) is always true.
Loading history...
86
            return false;
87
        }
88
89
        $roman = array(
90
            'M' => 1000,
91
            'D' => 500,
92
            'C' => 100,
93
            'L' => 50,
94
            'X' => 10,
95
            'V' => 5,
96
            'I' => 1,
97
        );
98
        $amount = [];
99
        foreach ($roman as $k => $v) {
100
            if (($amount[$k] = floor($number / $v)) > 0) {
101
                $number -= $amount[$k] * $v;
102
            }
103
        }
104
105
        // Build the string:
106
        $return = '';
107
        $oldK = '';
108
        foreach ($amount as $k => $v) {
109
            $return .= $v <= 3 ? str_repeat($k, $v) : $k . $oldK;
110
            $oldK = $k;
111
        }
112
        return str_replace(array('VIV', 'LXL', 'DCD'), array('IX', 'XC', 'CM'), $return);
113
    }
114
115
    /**
116
     * 函数将数字四舍五入到指定的位数
117
     *
118
     * @param double $number 必需。 要四舍五入的数字
119
     * @param integer $digits 要进行四舍五入运算的位数
120
     *
121
     * @return double
122
     */
123
    public static function round($number, $digits = 0)
124
    {
125
        return round($number, $digits);
126
    }
127
128
    /**
129
     * 朝着零的方向将数字进行向下舍入
130
     *
131
     * @param double $number 必需。需要向下舍入的任意实数
132
     * @param integer $digits 要将数字舍入到的位数
133
     *
134
     * @return double
135
     */
136
    public static function rounddown($number, $digits = 0)
137
    {
138
        $sign = $number >= 0 ? 1 : -1;
139
        return round(abs($number) - 0.5 * pow(10, -$digits), $digits) * $sign;
140
    }
141
142
    /**
143
     * 朝着远离 0(零)的方向将数字进行向上舍入
144
     *
145
     * @param double $number 必需。需要向下舍入的任意实数
146
     * @param integer $digits 要将数字舍入到的位数
147
     *
148
     * @return double
149
     */
150
    public static function roundup($number, $digits = 0)
151
    {
152
        $sign = $number >= 0 ? 1 : -1;
153
        return round(abs($number) + 0.5 * pow(10, -$digits), $digits) * $sign;
154
    }
155
}
156