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

FMAT   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Test Coverage

Coverage 38.89%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 16
c 1
b 0
f 0
dl 0
loc 56
ccs 7
cts 18
cp 0.3889
rs 10
wmc 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A floor() 0 3 3
A fact() 0 11 3
A factdouble() 0 11 4
1
<?php
2
/**
3
 * Trait MathAndTrigonometry-F
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
use icy2003\php\ihelpers\Arrays;
12
13
/**
14
 * MathAndTrigonometry-F
15
 */
16
trait FMAT
17
{
18
    /**
19
     * 返回数的阶乘
20
     *
21
     * @param integer|double $number 必需。 要计算其阶乘的非负数。 如果 number 不是整数,将被截尾取整
22
     *
23
     * @return integer
24
     */
25 2
    public static function fact($number)
26
    {
27 2
        $number = (int) floor($number);
28 2
        if ($number == 0) {
29
            return 1;
30
        }
31 2
        $result = 1;
32 2
        foreach (Arrays::rangeGenerator(1, $number) as $num) {
33 2
            $result *= $num;
34
        }
35 2
        return $result;
36
    }
37
38
    /**
39
     * 返回数字的双倍阶乘
40
     *
41
     * - 偶数:n!! = n * (n - 2) * (n - 4) * ... * 4 * 2
42
     * - 奇数:n!! = n * (n - 2) * (n - 4) * ... * 3 * 1
43
     *
44
     * @param integer $number 必需。 为其返回双倍阶乘的值。 如果 number 不是整数,将被截尾取整
45
     *
46
     * @return integer
47
     */
48
    public static function factdouble($number)
49
    {
50
        if ($number == 0) {
51
            return 1;
52
        }
53
        $result = 1;
54
        $isEven = $number % 2 == 0;
55
        foreach (Arrays::rangeGenerator($isEven ? 2 : 1, (int) $number, 2) as $num) {
56
            $result *= $num;
57
        }
58
        return $result;
59
    }
60
61
    /**
62
     * 将参数 number 向下舍入(沿绝对值减小的方向)为最接近的 significance 的倍数
63
     *
64
     * @param double $number 必需。 要舍入的数值
65
     * @param double $significance 必需。 要舍入到的倍数
66
     *
67
     * @return double
68
     */
69
    public static function floor($number, $significance = 1)
70
    {
71
        return (is_numeric($number) && is_numeric($significance)) ? (floor($number / $significance) * $significance) : false;
0 ignored issues
show
introduced by
The condition is_numeric($significance) is always true.
Loading history...
72
    }
73
}
74