Passed
Push — master ( 4b8292...9204d2 )
by Mark
10:15
created

Secant   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
c 1
b 0
f 0
dl 0
loc 40
ccs 10
cts 10
cp 1
rs 10
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A sec() 0 9 2
A sech() 0 9 2
1
<?php
2
3
namespace PhpOffice\PhpSpreadsheet\Calculation\MathTrig\Trig;
4
5
use PhpOffice\PhpSpreadsheet\Calculation\Exception;
6
use PhpOffice\PhpSpreadsheet\Calculation\MathTrig\Helpers;
7
8
class Secant
9
{
10
    /**
11
     * SEC.
12
     *
13
     * Returns the secant of an angle.
14
     *
15
     * @param float $angle Number
16
     *
17
     * @return float|string The secant of the angle
18
     */
19 21
    public static function sec($angle)
20
    {
21
        try {
22 21
            $angle = Helpers::validateNumericNullBool($angle);
23 1
        } catch (Exception $e) {
24 1
            return $e->getMessage();
25
        }
26
27 20
        return Helpers::verySmallDenominator(1.0, cos($angle));
28
    }
29
30
    /**
31
     * SECH.
32
     *
33
     * Returns the hyperbolic secant of an angle.
34
     *
35
     * @param float $angle Number
36
     *
37
     * @return float|string The hyperbolic secant of the angle
38
     */
39 19
    public static function sech($angle)
40
    {
41
        try {
42 19
            $angle = Helpers::validateNumericNullBool($angle);
43 1
        } catch (Exception $e) {
44 1
            return $e->getMessage();
45
        }
46
47 18
        return Helpers::verySmallDenominator(1.0, cosh($angle));
48
    }
49
}
50