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

Secant::sech()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 5
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 9
ccs 5
cts 5
cp 1
crap 2
rs 10
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