Start Grouping the trig functions related to sine and cosine into one class each, and rename methods
This commit is contained in:
parent
fe5fde26bb
commit
0c26333e96
|
|
@ -246,12 +246,12 @@ class Calculation
|
|||
],
|
||||
'ACOS' => [
|
||||
'category' => Category::CATEGORY_MATH_AND_TRIG,
|
||||
'functionCall' => [MathTrig\Acos::class, 'evaluate'],
|
||||
'functionCall' => [MathTrig\Trig\Cosine::class, 'acos'],
|
||||
'argumentCount' => '1',
|
||||
],
|
||||
'ACOSH' => [
|
||||
'category' => Category::CATEGORY_MATH_AND_TRIG,
|
||||
'functionCall' => [MathTrig\Acosh::class, 'evaluate'],
|
||||
'functionCall' => [MathTrig\Trig\Cosine::class, 'acosh'],
|
||||
'argumentCount' => '1',
|
||||
],
|
||||
'ACOT' => [
|
||||
|
|
@ -306,12 +306,12 @@ class Calculation
|
|||
],
|
||||
'ASIN' => [
|
||||
'category' => Category::CATEGORY_MATH_AND_TRIG,
|
||||
'functionCall' => [MathTrig\Asin::class, 'evaluate'],
|
||||
'functionCall' => [MathTrig\Trig\Sine::class, 'asin'],
|
||||
'argumentCount' => '1',
|
||||
],
|
||||
'ASINH' => [
|
||||
'category' => Category::CATEGORY_MATH_AND_TRIG,
|
||||
'functionCall' => [MathTrig\Asinh::class, 'evaluate'],
|
||||
'functionCall' => [MathTrig\Trig\Sine::class, 'asinh'],
|
||||
'argumentCount' => '1',
|
||||
],
|
||||
'ATAN' => [
|
||||
|
|
@ -608,12 +608,12 @@ class Calculation
|
|||
],
|
||||
'COS' => [
|
||||
'category' => Category::CATEGORY_MATH_AND_TRIG,
|
||||
'functionCall' => [MathTrig\Cos::class, 'evaluate'],
|
||||
'functionCall' => [MathTrig\Trig\Cosine::class, 'cos'],
|
||||
'argumentCount' => '1',
|
||||
],
|
||||
'COSH' => [
|
||||
'category' => Category::CATEGORY_MATH_AND_TRIG,
|
||||
'functionCall' => [MathTrig\Cosh::class, 'evaluate'],
|
||||
'functionCall' => [MathTrig\Trig\Cosine::class, 'cosh'],
|
||||
'argumentCount' => '1',
|
||||
],
|
||||
'COT' => [
|
||||
|
|
@ -2208,12 +2208,12 @@ class Calculation
|
|||
],
|
||||
'SIN' => [
|
||||
'category' => Category::CATEGORY_MATH_AND_TRIG,
|
||||
'functionCall' => [MathTrig\Sin::class, 'evaluate'],
|
||||
'functionCall' => [MathTrig\Trig\Sine::class, 'sin'],
|
||||
'argumentCount' => '1',
|
||||
],
|
||||
'SINH' => [
|
||||
'category' => Category::CATEGORY_MATH_AND_TRIG,
|
||||
'functionCall' => [MathTrig\Sinh::class, 'evaluate'],
|
||||
'functionCall' => [MathTrig\Trig\Sine::class, 'sinh'],
|
||||
'argumentCount' => '1',
|
||||
],
|
||||
'SKEW' => [
|
||||
|
|
|
|||
|
|
@ -234,7 +234,7 @@ class MathTrig
|
|||
* @return float|string Rounded Number, or a string containing an error
|
||||
*
|
||||
*@see MathTrig\Floor::floor()
|
||||
* Use the evaluate() method in the MathTrig\Floor class instead
|
||||
* Use the floor() method in the MathTrig\Floor class instead
|
||||
*/
|
||||
public static function FLOOR($number, $significance = null)
|
||||
{
|
||||
|
|
@ -1161,8 +1161,8 @@ class MathTrig
|
|||
*
|
||||
* @Deprecated 1.18.0
|
||||
*
|
||||
* @See MathTrig\Acos::evaluate()
|
||||
* Use the evaluate method in the MathTrig\Acos class instead
|
||||
* @See MathTrig\Trig\Cosine::acos()
|
||||
* Use the acos method in the MathTrig\Trig\Cosine class instead
|
||||
*
|
||||
* Returns the result of builtin function acos after validating args.
|
||||
*
|
||||
|
|
@ -1172,7 +1172,7 @@ class MathTrig
|
|||
*/
|
||||
public static function builtinACOS($number)
|
||||
{
|
||||
return MathTrig\Acos::evaluate($number);
|
||||
return MathTrig\Trig\Cosine::acos($number);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1182,8 +1182,8 @@ class MathTrig
|
|||
*
|
||||
* @Deprecated 1.18.0
|
||||
*
|
||||
* @See MathTrig\Acosh::evaluate()
|
||||
* Use the evaluate method in the MathTrig\Acosh class instead
|
||||
* @See MathTrig\Trig\Cosine::acosh()
|
||||
* Use the acosh method in the MathTrig\Trig\Cosine class instead
|
||||
*
|
||||
* @param mixed $number Should be numeric
|
||||
*
|
||||
|
|
@ -1191,7 +1191,7 @@ class MathTrig
|
|||
*/
|
||||
public static function builtinACOSH($number)
|
||||
{
|
||||
return MathTrig\Acosh::evaluate($number);
|
||||
return MathTrig\Trig\Cosine::acosh($number);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1201,8 +1201,8 @@ class MathTrig
|
|||
*
|
||||
* @Deprecated 1.18.0
|
||||
*
|
||||
* @See MathTrig\Asin::evaluate()
|
||||
* Use the evaluate method in the MathTrig\Asin class instead
|
||||
* @See MathTrig\Trig\Sine::asin()
|
||||
* Use the asin method in the MathTrig\Trig\Sine class instead
|
||||
*
|
||||
* @param mixed $number Should be numeric
|
||||
*
|
||||
|
|
@ -1210,7 +1210,7 @@ class MathTrig
|
|||
*/
|
||||
public static function builtinASIN($number)
|
||||
{
|
||||
return MathTrig\Asin::evaluate($number);
|
||||
return MathTrig\Trig\Sine::asin($number);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1220,8 +1220,8 @@ class MathTrig
|
|||
*
|
||||
* @Deprecated 1.18.0
|
||||
*
|
||||
* @See MathTrig\Asinh::evaluate()
|
||||
* Use the evaluate method in the MathTrig\Asinh class instead
|
||||
* @See MathTrig\Trig\Sine::asinh()
|
||||
* Use the asinh method in the MathTrig\Trig\Sine class instead
|
||||
*
|
||||
* @param mixed $number Should be numeric
|
||||
*
|
||||
|
|
@ -1229,7 +1229,7 @@ class MathTrig
|
|||
*/
|
||||
public static function builtinASINH($number)
|
||||
{
|
||||
return MathTrig\Asinh::evaluate($number);
|
||||
return MathTrig\Trig\Sine::asinh($number);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1277,8 +1277,8 @@ class MathTrig
|
|||
*
|
||||
* @Deprecated 1.18.0
|
||||
*
|
||||
* @See MathTrig\Cos::evaluate()
|
||||
* Use the evaluate method in the MathTrig\Cos class instead
|
||||
* @See MathTrig\Trig\Cosine::cos()
|
||||
* Use the cos method in the MathTrig\Trig\Cosine class instead
|
||||
*
|
||||
* @param mixed $number Should be numeric
|
||||
*
|
||||
|
|
@ -1286,7 +1286,7 @@ class MathTrig
|
|||
*/
|
||||
public static function builtinCOS($number)
|
||||
{
|
||||
return MathTrig\Cos::evaluate($number);
|
||||
return MathTrig\Trig\Cosine::cos($number);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1296,8 +1296,8 @@ class MathTrig
|
|||
*
|
||||
* @Deprecated 1.18.0
|
||||
*
|
||||
* @See MathTrig\Cosh::evaluate()
|
||||
* Use the evaluate method in the MathTrig\Cosh class instead
|
||||
* @See MathTrig\Trig\Cosine::cosh()
|
||||
* Use the cosh method in the MathTrig\Trig\Cosine class instead
|
||||
*
|
||||
* @param mixed $number Should be numeric
|
||||
*
|
||||
|
|
@ -1305,7 +1305,7 @@ class MathTrig
|
|||
*/
|
||||
public static function builtinCOSH($number)
|
||||
{
|
||||
return MathTrig\Cosh::evaluate($number);
|
||||
return MathTrig\Trig\Cosine::cosh($number);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1410,16 +1410,16 @@ class MathTrig
|
|||
*
|
||||
* @Deprecated 1.18.0
|
||||
*
|
||||
* @See MathTrig\Sin::evaluate()
|
||||
* Use the evaluate method in the MathTrig\Sin class instead
|
||||
* @See MathTrig\Trig\Sine::evaluate()
|
||||
* Use the sin method in the MathTrig\Trig\Sine class instead
|
||||
*
|
||||
* @param mixed $number Should be numeric
|
||||
*
|
||||
* @return float|string Rounded number
|
||||
* @return float|string sine
|
||||
*/
|
||||
public static function builtinSIN($number)
|
||||
{
|
||||
return MathTrig\Sin::evaluate($number);
|
||||
return MathTrig\Trig\Sine::sin($number);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1429,8 +1429,8 @@ class MathTrig
|
|||
*
|
||||
* @Deprecated 1.18.0
|
||||
*
|
||||
* @See MathTrig\Sinh::evaluate()
|
||||
* Use the evaluate method in the MathTrig\Sinh class instead
|
||||
* @See MathTrig\Trig\Sine::sinh()
|
||||
* Use the sinh method in the MathTrig\Trig\Sine class instead
|
||||
*
|
||||
* @param mixed $number Should be numeric
|
||||
*
|
||||
|
|
@ -1438,7 +1438,7 @@ class MathTrig
|
|||
*/
|
||||
public static function builtinSINH($number)
|
||||
{
|
||||
return MathTrig\Sinh::evaluate($number);
|
||||
return MathTrig\Trig\Sine::sinh($number);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1,28 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheet\Calculation\MathTrig;
|
||||
|
||||
use Exception;
|
||||
|
||||
class Acos
|
||||
{
|
||||
/**
|
||||
* ACOS.
|
||||
*
|
||||
* Returns the arccosine of a number.
|
||||
*
|
||||
* @param float $number Number
|
||||
*
|
||||
* @return float|string The arccosine of the number
|
||||
*/
|
||||
public static function evaluate($number)
|
||||
{
|
||||
try {
|
||||
$number = Helpers::validateNumericNullBool($number);
|
||||
} catch (Exception $e) {
|
||||
return $e->getMessage();
|
||||
}
|
||||
|
||||
return Helpers::numberOrNan(acos($number));
|
||||
}
|
||||
}
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheet\Calculation\MathTrig;
|
||||
|
||||
use Exception;
|
||||
|
||||
class Acosh
|
||||
{
|
||||
/**
|
||||
* ACOSH.
|
||||
*
|
||||
* Returns the arc hyperbolic cosine of a number.
|
||||
*
|
||||
* @param float $number Number
|
||||
*
|
||||
* @return float|string The arccosine of the number, or an error string
|
||||
*/
|
||||
public static function evaluate($number)
|
||||
{
|
||||
try {
|
||||
$number = Helpers::validateNumericNullBool($number);
|
||||
} catch (Exception $e) {
|
||||
return $e->getMessage();
|
||||
}
|
||||
|
||||
return Helpers::numberOrNan(acosh($number));
|
||||
}
|
||||
}
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheet\Calculation\MathTrig;
|
||||
|
||||
use Exception;
|
||||
|
||||
class Asin
|
||||
{
|
||||
/**
|
||||
* ASIN.
|
||||
*
|
||||
* Returns the arcsine of a number.
|
||||
*
|
||||
* @param float $number Number
|
||||
*
|
||||
* @return float|string The arcsine of the number
|
||||
*/
|
||||
public static function evaluate($number)
|
||||
{
|
||||
try {
|
||||
$number = Helpers::validateNumericNullBool($number);
|
||||
} catch (Exception $e) {
|
||||
return $e->getMessage();
|
||||
}
|
||||
|
||||
return Helpers::numberOrNan(asin($number));
|
||||
}
|
||||
}
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheet\Calculation\MathTrig;
|
||||
|
||||
use Exception;
|
||||
|
||||
class Asinh
|
||||
{
|
||||
/**
|
||||
* ASINH.
|
||||
*
|
||||
* Returns the arc hyperbolic sine of a number.
|
||||
*
|
||||
* @param float $number Number
|
||||
*
|
||||
* @return float|string The arc hyperbolic sine of the number
|
||||
*/
|
||||
public static function evaluate($number)
|
||||
{
|
||||
try {
|
||||
$number = Helpers::validateNumericNullBool($number);
|
||||
} catch (Exception $e) {
|
||||
return $e->getMessage();
|
||||
}
|
||||
|
||||
return Helpers::numberOrNan(asinh($number));
|
||||
}
|
||||
}
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheet\Calculation\MathTrig;
|
||||
|
||||
use Exception;
|
||||
|
||||
class Cos
|
||||
{
|
||||
/**
|
||||
* COS.
|
||||
*
|
||||
* Returns the result of builtin function cos after validating args.
|
||||
*
|
||||
* @param mixed $number Should be numeric
|
||||
*
|
||||
* @return float|string cosine
|
||||
*/
|
||||
public static function evaluate($number)
|
||||
{
|
||||
try {
|
||||
$number = Helpers::validateNumericNullBool($number);
|
||||
} catch (Exception $e) {
|
||||
return $e->getMessage();
|
||||
}
|
||||
|
||||
return cos($number);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheet\Calculation\MathTrig;
|
||||
|
||||
use Exception;
|
||||
|
||||
class Cosh
|
||||
{
|
||||
/**
|
||||
* COSH.
|
||||
*
|
||||
* Returns the result of builtin function cosh after validating args.
|
||||
*
|
||||
* @param mixed $number Should be numeric
|
||||
*
|
||||
* @return float|string cosine
|
||||
*/
|
||||
public static function evaluate($number)
|
||||
{
|
||||
try {
|
||||
$number = Helpers::validateNumericNullBool($number);
|
||||
} catch (Exception $e) {
|
||||
return $e->getMessage();
|
||||
}
|
||||
|
||||
return cosh($number);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheet\Calculation\MathTrig;
|
||||
|
||||
use Exception;
|
||||
|
||||
class Sin
|
||||
{
|
||||
/**
|
||||
* SIN.
|
||||
*
|
||||
* Returns the result of builtin function sin after validating args.
|
||||
*
|
||||
* @param mixed $angle Should be numeric
|
||||
*
|
||||
* @return float|string Rounded number
|
||||
*/
|
||||
public static function evaluate($angle)
|
||||
{
|
||||
try {
|
||||
$angle = Helpers::validateNumericNullBool($angle);
|
||||
} catch (Exception $e) {
|
||||
return $e->getMessage();
|
||||
}
|
||||
|
||||
return sin($angle);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheet\Calculation\MathTrig;
|
||||
|
||||
use Exception;
|
||||
|
||||
class Sinh
|
||||
{
|
||||
/**
|
||||
* SINH.
|
||||
*
|
||||
* Returns the result of builtin function sinh after validating args.
|
||||
*
|
||||
* @param mixed $angle Should be numeric
|
||||
*
|
||||
* @return float|string Rounded number
|
||||
*/
|
||||
public static function evaluate($angle)
|
||||
{
|
||||
try {
|
||||
$angle = Helpers::validateNumericNullBool($angle);
|
||||
} catch (Exception $e) {
|
||||
return $e->getMessage();
|
||||
}
|
||||
|
||||
return sinh($angle);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,89 @@
|
|||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheet\Calculation\MathTrig\Trig;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Exception;
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\MathTrig\Helpers;
|
||||
|
||||
class Cosine
|
||||
{
|
||||
/**
|
||||
* COS.
|
||||
*
|
||||
* Returns the result of builtin function cos after validating args.
|
||||
*
|
||||
* @param mixed $number Should be numeric
|
||||
*
|
||||
* @return float|string cosine
|
||||
*/
|
||||
public static function cos($number)
|
||||
{
|
||||
try {
|
||||
$number = Helpers::validateNumericNullBool($number);
|
||||
} catch (Exception $e) {
|
||||
return $e->getMessage();
|
||||
}
|
||||
|
||||
return cos($number);
|
||||
}
|
||||
|
||||
/**
|
||||
* COSH.
|
||||
*
|
||||
* Returns the result of builtin function cosh after validating args.
|
||||
*
|
||||
* @param mixed $number Should be numeric
|
||||
*
|
||||
* @return float|string hyperbolic cosine
|
||||
*/
|
||||
public static function cosh($number)
|
||||
{
|
||||
try {
|
||||
$number = Helpers::validateNumericNullBool($number);
|
||||
} catch (Exception $e) {
|
||||
return $e->getMessage();
|
||||
}
|
||||
|
||||
return cosh($number);
|
||||
}
|
||||
|
||||
/**
|
||||
* ACOS.
|
||||
*
|
||||
* Returns the arccosine of a number.
|
||||
*
|
||||
* @param float $number Number
|
||||
*
|
||||
* @return float|string The arccosine of the number
|
||||
*/
|
||||
public static function acos($number)
|
||||
{
|
||||
try {
|
||||
$number = Helpers::validateNumericNullBool($number);
|
||||
} catch (Exception $e) {
|
||||
return $e->getMessage();
|
||||
}
|
||||
|
||||
return Helpers::numberOrNan(acos($number));
|
||||
}
|
||||
|
||||
/**
|
||||
* ACOSH.
|
||||
*
|
||||
* Returns the arc inverse hyperbolic cosine of a number.
|
||||
*
|
||||
* @param float $number Number
|
||||
*
|
||||
* @return float|string The inverse hyperbolic cosine of the number, or an error string
|
||||
*/
|
||||
public static function acosh($number)
|
||||
{
|
||||
try {
|
||||
$number = Helpers::validateNumericNullBool($number);
|
||||
} catch (Exception $e) {
|
||||
return $e->getMessage();
|
||||
}
|
||||
|
||||
return Helpers::numberOrNan(acosh($number));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,89 @@
|
|||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheet\Calculation\MathTrig\Trig;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Exception;
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\MathTrig\Helpers;
|
||||
|
||||
class Sine
|
||||
{
|
||||
/**
|
||||
* SIN.
|
||||
*
|
||||
* Returns the result of builtin function sin after validating args.
|
||||
*
|
||||
* @param mixed $angle Should be numeric
|
||||
*
|
||||
* @return float|string sine
|
||||
*/
|
||||
public static function sin($angle)
|
||||
{
|
||||
try {
|
||||
$angle = Helpers::validateNumericNullBool($angle);
|
||||
} catch (Exception $e) {
|
||||
return $e->getMessage();
|
||||
}
|
||||
|
||||
return sin($angle);
|
||||
}
|
||||
|
||||
/**
|
||||
* SINH.
|
||||
*
|
||||
* Returns the result of builtin function sinh after validating args.
|
||||
*
|
||||
* @param mixed $angle Should be numeric
|
||||
*
|
||||
* @return float|string hyperbolic sine
|
||||
*/
|
||||
public static function sinh($angle)
|
||||
{
|
||||
try {
|
||||
$angle = Helpers::validateNumericNullBool($angle);
|
||||
} catch (Exception $e) {
|
||||
return $e->getMessage();
|
||||
}
|
||||
|
||||
return sinh($angle);
|
||||
}
|
||||
|
||||
/**
|
||||
* ASIN.
|
||||
*
|
||||
* Returns the arcsine of a number.
|
||||
*
|
||||
* @param float $number Number
|
||||
*
|
||||
* @return float|string The arcsine of the number
|
||||
*/
|
||||
public static function asin($number)
|
||||
{
|
||||
try {
|
||||
$number = Helpers::validateNumericNullBool($number);
|
||||
} catch (Exception $e) {
|
||||
return $e->getMessage();
|
||||
}
|
||||
|
||||
return Helpers::numberOrNan(asin($number));
|
||||
}
|
||||
|
||||
/**
|
||||
* ASINH.
|
||||
*
|
||||
* Returns the inverse hyperbolic sine of a number.
|
||||
*
|
||||
* @param float $number Number
|
||||
*
|
||||
* @return float|string The inverse hyperbolic sine of the number
|
||||
*/
|
||||
public static function asinh($number)
|
||||
{
|
||||
try {
|
||||
$number = Helpers::validateNumericNullBool($number);
|
||||
} catch (Exception $e) {
|
||||
return $e->getMessage();
|
||||
}
|
||||
|
||||
return Helpers::numberOrNan(asinh($number));
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue