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

Cosecant::csc()   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 Cosecant
9
{
10
    /**
11
     * CSC.
12
     *
13
     * Returns the cosecant of an angle.
14
     *
15
     * @param float $angle Number
16
     *
17
     * @return float|string The cosecant of the angle
18
     */
19 18
    public static function csc($angle)
20
    {
21
        try {
22 18
            $angle = Helpers::validateNumericNullBool($angle);
23 1
        } catch (Exception $e) {
24 1
            return $e->getMessage();
25
        }
26
27 17
        return Helpers::verySmallDenominator(1.0, sin($angle));
28
    }
29
30
    /**
31
     * CSCH.
32
     *
33
     * Returns the hyperbolic cosecant of an angle.
34
     *
35
     * @param float $angle Number
36
     *
37
     * @return float|string The hyperbolic cosecant of the angle
38
     */
39 20
    public static function csch($angle)
40
    {
41
        try {
42 20
            $angle = Helpers::validateNumericNullBool($angle);
43 1
        } catch (Exception $e) {
44 1
            return $e->getMessage();
45
        }
46
47 19
        return Helpers::verySmallDenominator(1.0, sinh($angle));
48
    }
49
}
50