Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1441 ariadna 1
<?php
2
 
3
namespace PhpOffice\PhpSpreadsheet\Calculation\MathTrig;
4
 
5
use PhpOffice\PhpSpreadsheet\Calculation\ArrayEnabled;
6
use PhpOffice\PhpSpreadsheet\Calculation\Exception;
7
 
8
class Angle
9
{
10
    use ArrayEnabled;
11
 
12
    /**
13
     * DEGREES.
14
     *
15
     * Returns the result of builtin function rad2deg after validating args.
16
     *
17
     * @param mixed $number Should be numeric, or can be an array of numbers
18
     *
19
     * @return array|float|string Rounded number
20
     *         If an array of numbers is passed as the argument, then the returned result will also be an array
21
     *            with the same dimensions
22
     */
23
    public static function toDegrees(mixed $number): array|string|float
24
    {
25
        if (is_array($number)) {
26
            return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $number);
27
        }
28
 
29
        try {
30
            $number = Helpers::validateNumericNullBool($number);
31
        } catch (Exception $e) {
32
            return $e->getMessage();
33
        }
34
 
35
        return rad2deg($number);
36
    }
37
 
38
    /**
39
     * RADIANS.
40
     *
41
     * Returns the result of builtin function deg2rad after validating args.
42
     *
43
     * @param mixed $number Should be numeric, or can be an array of numbers
44
     *
45
     * @return array|float|string Rounded number
46
     *         If an array of numbers is passed as the argument, then the returned result will also be an array
47
     *            with the same dimensions
48
     */
49
    public static function toRadians(mixed $number): array|string|float
50
    {
51
        if (is_array($number)) {
52
            return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $number);
53
        }
54
 
55
        try {
56
            $number = Helpers::validateNumericNullBool($number);
57
        } catch (Exception $e) {
58
            return $e->getMessage();
59
        }
60
 
61
        return deg2rad($number);
62
    }
63
}