Merge pull request #2580 from PHPOffice/Issue-2551-Array-Ready-Function-Financial
Issue 2551 - array ready functions - Text (phase #1)
This commit is contained in:
commit
6a2905a34c
|
|
@ -927,7 +927,12 @@ parameters:
|
|||
|
||||
-
|
||||
message: "#^Parameter \\#1 \\$year of static method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Helpers\\:\\:daysPerYear\\(\\) expects int\\|string, array\\|int\\|string given\\.$#"
|
||||
count: 3
|
||||
count: 1
|
||||
path: src/PhpSpreadsheet/Calculation/Financial/Coupons.php
|
||||
|
||||
-
|
||||
message: "#^Parameter \\#1 \\$year of static method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Helpers\\:\\:daysPerYear\\(\\) expects int\\|string, mixed given\\.$#"
|
||||
count: 2
|
||||
path: src/PhpSpreadsheet/Calculation/Financial/Coupons.php
|
||||
|
||||
-
|
||||
|
|
@ -961,12 +966,12 @@ parameters:
|
|||
path: src/PhpSpreadsheet/Calculation/Financial/Depreciation.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Securities\\\\AccruedInterest\\:\\:atMaturity\\(\\) should return float\\|string but returns array\\|string\\.$#"
|
||||
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Securities\\\\AccruedInterest\\:\\:atMaturity\\(\\) should return float\\|string but returns mixed\\.$#"
|
||||
count: 1
|
||||
path: src/PhpSpreadsheet/Calculation/Financial/Securities/AccruedInterest.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Securities\\\\AccruedInterest\\:\\:periodic\\(\\) should return float\\|string but returns array\\|string\\.$#"
|
||||
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Securities\\\\AccruedInterest\\:\\:periodic\\(\\) should return float\\|string but returns mixed\\.$#"
|
||||
count: 2
|
||||
path: src/PhpSpreadsheet/Calculation/Financial/Securities/AccruedInterest.php
|
||||
|
||||
|
|
@ -976,12 +981,12 @@ parameters:
|
|||
path: src/PhpSpreadsheet/Calculation/Financial/Securities/Price.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Securities\\\\Price\\:\\:priceAtMaturity\\(\\) should return float\\|string but returns array\\|string\\.$#"
|
||||
count: 3
|
||||
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Securities\\\\Price\\:\\:priceAtMaturity\\(\\) should return float\\|string but returns mixed\\.$#"
|
||||
count: 4
|
||||
path: src/PhpSpreadsheet/Calculation/Financial/Securities/Price.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Securities\\\\Price\\:\\:priceDiscounted\\(\\) should return float\\|string but returns array\\|string\\.$#"
|
||||
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Securities\\\\Price\\:\\:priceDiscounted\\(\\) should return float\\|string but returns mixed\\.$#"
|
||||
count: 1
|
||||
path: src/PhpSpreadsheet/Calculation/Financial/Securities/Price.php
|
||||
|
||||
|
|
@ -996,22 +1001,22 @@ parameters:
|
|||
path: src/PhpSpreadsheet/Calculation/Financial/Securities/Price.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Securities\\\\Rates\\:\\:discount\\(\\) should return float\\|string but returns array\\|string\\.$#"
|
||||
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Securities\\\\Rates\\:\\:discount\\(\\) should return float\\|string but returns mixed\\.$#"
|
||||
count: 1
|
||||
path: src/PhpSpreadsheet/Calculation/Financial/Securities/Rates.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Securities\\\\Rates\\:\\:interest\\(\\) should return float\\|string but returns array\\|string\\.$#"
|
||||
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Securities\\\\Rates\\:\\:interest\\(\\) should return float\\|string but returns mixed\\.$#"
|
||||
count: 1
|
||||
path: src/PhpSpreadsheet/Calculation/Financial/Securities/Rates.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Securities\\\\Yields\\:\\:yieldAtMaturity\\(\\) should return float\\|string but returns array\\|string\\.$#"
|
||||
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Securities\\\\Yields\\:\\:yieldAtMaturity\\(\\) should return float\\|string but returns mixed\\.$#"
|
||||
count: 3
|
||||
path: src/PhpSpreadsheet/Calculation/Financial/Securities/Yields.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Securities\\\\Yields\\:\\:yieldDiscounted\\(\\) should return float\\|string but returns array\\|string\\.$#"
|
||||
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Securities\\\\Yields\\:\\:yieldDiscounted\\(\\) should return float\\|string but returns mixed\\.$#"
|
||||
count: 1
|
||||
path: src/PhpSpreadsheet/Calculation/Financial/Securities/Yields.php
|
||||
|
||||
|
|
@ -1021,7 +1026,7 @@ parameters:
|
|||
path: src/PhpSpreadsheet/Calculation/Financial/Securities/Yields.php
|
||||
|
||||
-
|
||||
message: "#^Parameter \\#1 \\$year of static method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Helpers\\:\\:daysPerYear\\(\\) expects int\\|string, array\\|int\\|string given\\.$#"
|
||||
message: "#^Parameter \\#1 \\$year of static method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Helpers\\:\\:daysPerYear\\(\\) expects int\\|string, mixed given\\.$#"
|
||||
count: 3
|
||||
path: src/PhpSpreadsheet/Calculation/Financial/TreasuryBill.php
|
||||
|
||||
|
|
@ -1925,21 +1930,6 @@ parameters:
|
|||
count: 1
|
||||
path: src/PhpSpreadsheet/Calculation/TextData.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\TextData\\:\\:SEARCHINSENSITIVE\\(\\) should return string but returns int\\|string\\.$#"
|
||||
count: 1
|
||||
path: src/PhpSpreadsheet/Calculation/TextData.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\TextData\\:\\:SEARCHSENSITIVE\\(\\) should return string but returns int\\|string\\.$#"
|
||||
count: 1
|
||||
path: src/PhpSpreadsheet/Calculation/TextData.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\TextData\\:\\:TRIMNONPRINTABLE\\(\\) should return string but returns string\\|null\\.$#"
|
||||
count: 1
|
||||
path: src/PhpSpreadsheet/Calculation/TextData.php
|
||||
|
||||
-
|
||||
message: "#^Parameter \\#1 \\$glue of function implode expects string, mixed given\\.$#"
|
||||
count: 1
|
||||
|
|
|
|||
|
|
@ -30,6 +30,8 @@ class NetworkDays
|
|||
* @param mixed $dateArgs An array of dates (such as holidays) to exclude from the calculation
|
||||
*
|
||||
* @return array|int|string Interval between the dates
|
||||
* If an array of values is passed for the $startDate or $endDate arguments, then the returned result
|
||||
* will also be an array with matching dimensions
|
||||
*/
|
||||
public static function count($startDate, $endDate, ...$dateArgs)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ class YearFrac
|
|||
*
|
||||
* @param mixed $startDate Excel date serial value (float), PHP date timestamp (integer),
|
||||
* PHP DateTime object, or a standard date string
|
||||
* Or can be an array of methods
|
||||
* Or can be an array of values
|
||||
* @param mixed $endDate Excel date serial value (float), PHP date timestamp (integer),
|
||||
* PHP DateTime object, or a standard date string
|
||||
* Or can be an array of methods
|
||||
|
|
|
|||
|
|
@ -587,10 +587,10 @@ class Financial
|
|||
* @see Financial\Dollar::decimal()
|
||||
* Use the decimal() method in the Financial\Dollar class instead
|
||||
*
|
||||
* @param float $fractional_dollar Fractional Dollar
|
||||
* @param int $fraction Fraction
|
||||
* @param array|float $fractional_dollar Fractional Dollar
|
||||
* @param array|int $fraction Fraction
|
||||
*
|
||||
* @return float|string
|
||||
* @return array|float|string
|
||||
*/
|
||||
public static function DOLLARDE($fractional_dollar = null, $fraction = 0)
|
||||
{
|
||||
|
|
@ -612,10 +612,10 @@ class Financial
|
|||
* @see Financial\Dollar::fractional()
|
||||
* Use the fractional() method in the Financial\Dollar class instead
|
||||
*
|
||||
* @param float $decimal_dollar Decimal Dollar
|
||||
* @param int $fraction Fraction
|
||||
* @param array|float $decimal_dollar Decimal Dollar
|
||||
* @param array|int $fraction Fraction
|
||||
*
|
||||
* @return float|string
|
||||
* @return array|float|string
|
||||
*/
|
||||
public static function DOLLARFR($decimal_dollar = null, $fraction = 0)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -168,7 +168,7 @@ class Amortization
|
|||
|
||||
if (
|
||||
($basis == FinancialConstants::BASIS_DAYS_PER_YEAR_ACTUAL) &&
|
||||
($yearFrac < 1) && (DateTimeExcel\Helpers::isLeapYear($purchasedYear))
|
||||
($yearFrac < 1) && (Functions::scalar(DateTimeExcel\Helpers::isLeapYear($purchasedYear)))
|
||||
) {
|
||||
$yearFrac *= 365 / 366;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ class Coupons
|
|||
return $e->getMessage();
|
||||
}
|
||||
|
||||
$daysPerYear = Helpers::daysPerYear(DateTimeExcel\DateParts::year($settlement), $basis);
|
||||
$daysPerYear = Helpers::daysPerYear(Functions::scalar(DateTimeExcel\DateParts::year($settlement)), $basis);
|
||||
if (is_string($daysPerYear)) {
|
||||
return Functions::VALUE();
|
||||
}
|
||||
|
|
@ -134,7 +134,7 @@ class Coupons
|
|||
case FinancialConstants::BASIS_DAYS_PER_YEAR_ACTUAL:
|
||||
// Actual/actual
|
||||
if ($frequency == FinancialConstants::FREQUENCY_ANNUAL) {
|
||||
$daysPerYear = (int) Helpers::daysPerYear(DateTimeExcel\DateParts::year($settlement), $basis);
|
||||
$daysPerYear = (int) Helpers::daysPerYear(Functions::scalar(DateTimeExcel\DateParts::year($settlement)), $basis);
|
||||
|
||||
return $daysPerYear / $frequency;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,22 +2,26 @@
|
|||
|
||||
namespace PhpOffice\PhpSpreadsheet\Calculation\Financial;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\ArrayEnabled;
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Exception;
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\TextData\Format;
|
||||
|
||||
class Dollar
|
||||
{
|
||||
use ArrayEnabled;
|
||||
|
||||
/**
|
||||
* DOLLAR.
|
||||
*
|
||||
* This function converts a number to text using currency format, with the decimals rounded to the specified place.
|
||||
* The format used is $#,##0.00_);($#,##0.00)..
|
||||
*
|
||||
* @param mixed $number The value to format
|
||||
* @param mixed $number The value to format, or can be an array of numbers
|
||||
* @param mixed $precision The number of digits to display to the right of the decimal point (as an integer).
|
||||
* If precision is negative, number is rounded to the left of the decimal point.
|
||||
* If you omit precision, it is assumed to be 2
|
||||
* Or can be an array of precision values
|
||||
*/
|
||||
public static function format($number, $precision = 2): string
|
||||
{
|
||||
|
|
@ -35,12 +39,18 @@ class Dollar
|
|||
* DOLLARDE(fractional_dollar,fraction)
|
||||
*
|
||||
* @param mixed $fractionalDollar Fractional Dollar
|
||||
* Or can be an array of values
|
||||
* @param mixed $fraction Fraction
|
||||
* Or can be an array of values
|
||||
*
|
||||
* @return float|string
|
||||
* @return array|float|string
|
||||
*/
|
||||
public static function decimal($fractionalDollar = null, $fraction = 0)
|
||||
{
|
||||
if (is_array($fractionalDollar) || is_array($fraction)) {
|
||||
return self::evaluateArrayArguments([self::class, __FUNCTION__], $fractionalDollar, $fraction);
|
||||
}
|
||||
|
||||
try {
|
||||
$fractionalDollar = FinancialValidations::validateFloat(
|
||||
Functions::flattenSingleValue($fractionalDollar) ?? 0.0
|
||||
|
|
@ -58,8 +68,8 @@ class Dollar
|
|||
return Functions::DIV0();
|
||||
}
|
||||
|
||||
$dollars = ($fractionalDollar < 0.0) ? ceil($fractionalDollar) : floor($fractionalDollar);
|
||||
$cents = fmod($fractionalDollar, 1);
|
||||
$dollars = ($fractionalDollar < 0) ? ceil($fractionalDollar) : floor($fractionalDollar);
|
||||
$cents = fmod($fractionalDollar, 1.0);
|
||||
$cents /= $fraction;
|
||||
$cents *= 10 ** ceil(log10($fraction));
|
||||
|
||||
|
|
@ -77,12 +87,18 @@ class Dollar
|
|||
* DOLLARFR(decimal_dollar,fraction)
|
||||
*
|
||||
* @param mixed $decimalDollar Decimal Dollar
|
||||
* Or can be an array of values
|
||||
* @param mixed $fraction Fraction
|
||||
* Or can be an array of values
|
||||
*
|
||||
* @return float|string
|
||||
* @return array|float|string
|
||||
*/
|
||||
public static function fractional($decimalDollar = null, $fraction = 0)
|
||||
{
|
||||
if (is_array($decimalDollar) || is_array($fraction)) {
|
||||
return self::evaluateArrayArguments([self::class, __FUNCTION__], $decimalDollar, $fraction);
|
||||
}
|
||||
|
||||
try {
|
||||
$decimalDollar = FinancialValidations::validateFloat(
|
||||
Functions::flattenSingleValue($decimalDollar) ?? 0.0
|
||||
|
|
|
|||
|
|
@ -78,12 +78,12 @@ class AccruedInterest
|
|||
return $e->getMessage();
|
||||
}
|
||||
|
||||
$daysBetweenIssueAndSettlement = YearFrac::fraction($issue, $settlement, $basis);
|
||||
$daysBetweenIssueAndSettlement = Functions::scalar(YearFrac::fraction($issue, $settlement, $basis));
|
||||
if (!is_numeric($daysBetweenIssueAndSettlement)) {
|
||||
// return date error
|
||||
return $daysBetweenIssueAndSettlement;
|
||||
}
|
||||
$daysBetweenFirstInterestAndSettlement = YearFrac::fraction($firstInterest, $settlement, $basis);
|
||||
$daysBetweenFirstInterestAndSettlement = Functions::scalar(YearFrac::fraction($firstInterest, $settlement, $basis));
|
||||
if (!is_numeric($daysBetweenFirstInterestAndSettlement)) {
|
||||
// return date error
|
||||
return $daysBetweenFirstInterestAndSettlement;
|
||||
|
|
@ -140,7 +140,7 @@ class AccruedInterest
|
|||
return $e->getMessage();
|
||||
}
|
||||
|
||||
$daysBetweenIssueAndSettlement = YearFrac::fraction($issue, $settlement, $basis);
|
||||
$daysBetweenIssueAndSettlement = Functions::scalar(YearFrac::fraction($issue, $settlement, $basis));
|
||||
if (!is_numeric($daysBetweenIssueAndSettlement)) {
|
||||
// return date error
|
||||
return $daysBetweenIssueAndSettlement;
|
||||
|
|
|
|||
|
|
@ -134,7 +134,7 @@ class Price
|
|||
return $e->getMessage();
|
||||
}
|
||||
|
||||
$daysBetweenSettlementAndMaturity = DateTimeExcel\YearFrac::fraction($settlement, $maturity, $basis);
|
||||
$daysBetweenSettlementAndMaturity = Functions::scalar(DateTimeExcel\YearFrac::fraction($settlement, $maturity, $basis));
|
||||
if (!is_numeric($daysBetweenSettlementAndMaturity)) {
|
||||
// return date error
|
||||
return $daysBetweenSettlementAndMaturity;
|
||||
|
|
@ -194,23 +194,23 @@ class Price
|
|||
return $e->getMessage();
|
||||
}
|
||||
|
||||
$daysPerYear = Helpers::daysPerYear(DateTimeExcel\DateParts::year($settlement), $basis);
|
||||
$daysPerYear = Functions::scalar(Helpers::daysPerYear(DateTimeExcel\DateParts::year($settlement), $basis));
|
||||
if (!is_numeric($daysPerYear)) {
|
||||
return $daysPerYear;
|
||||
}
|
||||
$daysBetweenIssueAndSettlement = DateTimeExcel\YearFrac::fraction($issue, $settlement, $basis);
|
||||
$daysBetweenIssueAndSettlement = Functions::scalar(DateTimeExcel\YearFrac::fraction($issue, $settlement, $basis));
|
||||
if (!is_numeric($daysBetweenIssueAndSettlement)) {
|
||||
// return date error
|
||||
return $daysBetweenIssueAndSettlement;
|
||||
}
|
||||
$daysBetweenIssueAndSettlement *= $daysPerYear;
|
||||
$daysBetweenIssueAndMaturity = DateTimeExcel\YearFrac::fraction($issue, $maturity, $basis);
|
||||
$daysBetweenIssueAndMaturity = Functions::scalar(DateTimeExcel\YearFrac::fraction($issue, $maturity, $basis));
|
||||
if (!is_numeric($daysBetweenIssueAndMaturity)) {
|
||||
// return date error
|
||||
return $daysBetweenIssueAndMaturity;
|
||||
}
|
||||
$daysBetweenIssueAndMaturity *= $daysPerYear;
|
||||
$daysBetweenSettlementAndMaturity = DateTimeExcel\YearFrac::fraction($settlement, $maturity, $basis);
|
||||
$daysBetweenSettlementAndMaturity = Functions::scalar(DateTimeExcel\YearFrac::fraction($settlement, $maturity, $basis));
|
||||
if (!is_numeric($daysBetweenSettlementAndMaturity)) {
|
||||
// return date error
|
||||
return $daysBetweenSettlementAndMaturity;
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ class Rates
|
|||
return Functions::NAN();
|
||||
}
|
||||
|
||||
$daysBetweenSettlementAndMaturity = DateTimeExcel\YearFrac::fraction($settlement, $maturity, $basis);
|
||||
$daysBetweenSettlementAndMaturity = Functions::scalar(DateTimeExcel\YearFrac::fraction($settlement, $maturity, $basis));
|
||||
if (!is_numeric($daysBetweenSettlementAndMaturity)) {
|
||||
// return date error
|
||||
return $daysBetweenSettlementAndMaturity;
|
||||
|
|
@ -126,7 +126,7 @@ class Rates
|
|||
return Functions::NAN();
|
||||
}
|
||||
|
||||
$daysBetweenSettlementAndMaturity = DateTimeExcel\YearFrac::fraction($settlement, $maturity, $basis);
|
||||
$daysBetweenSettlementAndMaturity = Functions::scalar(DateTimeExcel\YearFrac::fraction($settlement, $maturity, $basis));
|
||||
if (!is_numeric($daysBetweenSettlementAndMaturity)) {
|
||||
// return date error
|
||||
return $daysBetweenSettlementAndMaturity;
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ class Yields
|
|||
if (!is_numeric($daysPerYear)) {
|
||||
return $daysPerYear;
|
||||
}
|
||||
$daysBetweenSettlementAndMaturity = DateTimeExcel\YearFrac::fraction($settlement, $maturity, $basis);
|
||||
$daysBetweenSettlementAndMaturity = Functions::scalar(DateTimeExcel\YearFrac::fraction($settlement, $maturity, $basis));
|
||||
if (!is_numeric($daysBetweenSettlementAndMaturity)) {
|
||||
// return date error
|
||||
return $daysBetweenSettlementAndMaturity;
|
||||
|
|
@ -126,19 +126,19 @@ class Yields
|
|||
if (!is_numeric($daysPerYear)) {
|
||||
return $daysPerYear;
|
||||
}
|
||||
$daysBetweenIssueAndSettlement = DateTimeExcel\YearFrac::fraction($issue, $settlement, $basis);
|
||||
$daysBetweenIssueAndSettlement = Functions::scalar(DateTimeExcel\YearFrac::fraction($issue, $settlement, $basis));
|
||||
if (!is_numeric($daysBetweenIssueAndSettlement)) {
|
||||
// return date error
|
||||
return $daysBetweenIssueAndSettlement;
|
||||
}
|
||||
$daysBetweenIssueAndSettlement *= $daysPerYear;
|
||||
$daysBetweenIssueAndMaturity = DateTimeExcel\YearFrac::fraction($issue, $maturity, $basis);
|
||||
$daysBetweenIssueAndMaturity = Functions::scalar(DateTimeExcel\YearFrac::fraction($issue, $maturity, $basis));
|
||||
if (!is_numeric($daysBetweenIssueAndMaturity)) {
|
||||
// return date error
|
||||
return $daysBetweenIssueAndMaturity;
|
||||
}
|
||||
$daysBetweenIssueAndMaturity *= $daysPerYear;
|
||||
$daysBetweenSettlementAndMaturity = DateTimeExcel\YearFrac::fraction($settlement, $maturity, $basis);
|
||||
$daysBetweenSettlementAndMaturity = Functions::scalar(DateTimeExcel\YearFrac::fraction($settlement, $maturity, $basis));
|
||||
if (!is_numeric($daysBetweenSettlementAndMaturity)) {
|
||||
// return date error
|
||||
return $daysBetweenSettlementAndMaturity;
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ class TreasuryBill
|
|||
|
||||
$daysBetweenSettlementAndMaturity = $maturity - $settlement;
|
||||
$daysPerYear = Helpers::daysPerYear(
|
||||
DateTimeExcel\DateParts::year($maturity),
|
||||
Functions::scalar(DateTimeExcel\DateParts::year($maturity)),
|
||||
FinancialConstants::BASIS_DAYS_PER_YEAR_ACTUAL
|
||||
);
|
||||
|
||||
|
|
@ -88,7 +88,7 @@ class TreasuryBill
|
|||
|
||||
$daysBetweenSettlementAndMaturity = $maturity - $settlement;
|
||||
$daysPerYear = Helpers::daysPerYear(
|
||||
DateTimeExcel\DateParts::year($maturity),
|
||||
Functions::scalar(DateTimeExcel\DateParts::year($maturity)),
|
||||
FinancialConstants::BASIS_DAYS_PER_YEAR_ACTUAL
|
||||
);
|
||||
|
||||
|
|
@ -134,7 +134,7 @@ class TreasuryBill
|
|||
|
||||
$daysBetweenSettlementAndMaturity = $maturity - $settlement;
|
||||
$daysPerYear = Helpers::daysPerYear(
|
||||
DateTimeExcel\DateParts::year($maturity),
|
||||
Functions::scalar(DateTimeExcel\DateParts::year($maturity)),
|
||||
FinancialConstants::BASIS_DAYS_PER_YEAR_ACTUAL
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ class Sqrt
|
|||
*
|
||||
* @param mixed $number Should be numeric, or can be an array of numbers
|
||||
*
|
||||
* @return array|float|string square roor
|
||||
* @return array|float|string square root
|
||||
* If an array of numbers is passed as the argument, then the returned result will also be an array
|
||||
* with the same dimensions
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ class TextData
|
|||
*
|
||||
* @param string $character Value
|
||||
*
|
||||
* @return string
|
||||
* @return array|string
|
||||
*/
|
||||
public static function CHARACTER($character)
|
||||
{
|
||||
|
|
@ -34,7 +34,7 @@ class TextData
|
|||
*
|
||||
* @param mixed $stringValue Value to check
|
||||
*
|
||||
* @return string
|
||||
* @return null|array|string
|
||||
*/
|
||||
public static function TRIMNONPRINTABLE($stringValue = '')
|
||||
{
|
||||
|
|
@ -50,7 +50,7 @@ class TextData
|
|||
*
|
||||
* @param mixed $stringValue Value to check
|
||||
*
|
||||
* @return string
|
||||
* @return array|string
|
||||
*/
|
||||
public static function TRIMSPACES($stringValue = '')
|
||||
{
|
||||
|
|
@ -64,9 +64,9 @@ class TextData
|
|||
*
|
||||
* @see Use the code() method in the TextData\CharacterConvert class instead
|
||||
*
|
||||
* @param string $characters Value
|
||||
* @param array|string $characters Value
|
||||
*
|
||||
* @return int|string A string if arguments are invalid
|
||||
* @return array|int|string A string if arguments are invalid
|
||||
*/
|
||||
public static function ASCIICODE($characters)
|
||||
{
|
||||
|
|
@ -110,17 +110,17 @@ class TextData
|
|||
}
|
||||
|
||||
/**
|
||||
* SEARCHSENSITIVE.
|
||||
* FIND.
|
||||
*
|
||||
* @Deprecated 1.18.0
|
||||
*
|
||||
* @see Use the sensitive() method in the TextData\Search class instead
|
||||
*
|
||||
* @param string $needle The string to look for
|
||||
* @param string $haystack The string in which to look
|
||||
* @param int $offset Offset within $haystack
|
||||
* @param array|string $needle The string to look for
|
||||
* @param array|string $haystack The string in which to look
|
||||
* @param array|int $offset Offset within $haystack
|
||||
*
|
||||
* @return string
|
||||
* @return array|int|string
|
||||
*/
|
||||
public static function SEARCHSENSITIVE($needle, $haystack, $offset = 1)
|
||||
{
|
||||
|
|
@ -128,17 +128,17 @@ class TextData
|
|||
}
|
||||
|
||||
/**
|
||||
* SEARCHINSENSITIVE.
|
||||
* SEARCH.
|
||||
*
|
||||
* @Deprecated 1.18.0
|
||||
*
|
||||
* @see Use the insensitive() method in the TextData\Search class instead
|
||||
*
|
||||
* @param string $needle The string to look for
|
||||
* @param string $haystack The string in which to look
|
||||
* @param int $offset Offset within $haystack
|
||||
* @param array|string $needle The string to look for
|
||||
* @param array|string $haystack The string in which to look
|
||||
* @param array|int $offset Offset within $haystack
|
||||
*
|
||||
* @return string
|
||||
* @return array|int|string
|
||||
*/
|
||||
public static function SEARCHINSENSITIVE($needle, $haystack, $offset = 1)
|
||||
{
|
||||
|
|
@ -170,10 +170,10 @@ class TextData
|
|||
*
|
||||
* @see Use the left() method in the TextData\Extract class instead
|
||||
*
|
||||
* @param string $value Value
|
||||
* @param int $chars Number of characters
|
||||
* @param array|string $value Value
|
||||
* @param array|int $chars Number of characters
|
||||
*
|
||||
* @return string
|
||||
* @return array|string
|
||||
*/
|
||||
public static function LEFT($value = '', $chars = 1)
|
||||
{
|
||||
|
|
@ -187,11 +187,11 @@ class TextData
|
|||
*
|
||||
* @see Use the mid() method in the TextData\Extract class instead
|
||||
*
|
||||
* @param string $value Value
|
||||
* @param int $start Start character
|
||||
* @param int $chars Number of characters
|
||||
* @param array|string $value Value
|
||||
* @param array|int $start Start character
|
||||
* @param array|int $chars Number of characters
|
||||
*
|
||||
* @return string
|
||||
* @return array|string
|
||||
*/
|
||||
public static function MID($value = '', $start = 1, $chars = null)
|
||||
{
|
||||
|
|
@ -205,10 +205,10 @@ class TextData
|
|||
*
|
||||
* @see Use the right() method in the TextData\Extract class instead
|
||||
*
|
||||
* @param string $value Value
|
||||
* @param int $chars Number of characters
|
||||
* @param array|string $value Value
|
||||
* @param array|int $chars Number of characters
|
||||
*
|
||||
* @return string
|
||||
* @return array|string
|
||||
*/
|
||||
public static function RIGHT($value = '', $chars = 1)
|
||||
{
|
||||
|
|
@ -234,15 +234,15 @@ class TextData
|
|||
/**
|
||||
* LOWERCASE.
|
||||
*
|
||||
* Converts a string value to upper case.
|
||||
* Converts a string value to lower case.
|
||||
*
|
||||
* @Deprecated 1.18.0
|
||||
*
|
||||
* @see Use the lower() method in the TextData\CaseConvert class instead
|
||||
*
|
||||
* @param string $mixedCaseString
|
||||
* @param array|string $mixedCaseString
|
||||
*
|
||||
* @return string
|
||||
* @return array|string
|
||||
*/
|
||||
public static function LOWERCASE($mixedCaseString)
|
||||
{
|
||||
|
|
@ -260,7 +260,7 @@ class TextData
|
|||
*
|
||||
* @param string $mixedCaseString
|
||||
*
|
||||
* @return string
|
||||
* @return array|string
|
||||
*/
|
||||
public static function UPPERCASE($mixedCaseString)
|
||||
{
|
||||
|
|
@ -270,15 +270,15 @@ class TextData
|
|||
/**
|
||||
* PROPERCASE.
|
||||
*
|
||||
* Converts a string value to upper case.
|
||||
* Converts a string value to proper/title case.
|
||||
*
|
||||
* @Deprecated 1.18.0
|
||||
*
|
||||
* @see Use the proper() method in the TextData\CaseConvert class instead
|
||||
*
|
||||
* @param string $mixedCaseString
|
||||
* @param array|string $mixedCaseString
|
||||
*
|
||||
* @return string
|
||||
* @return array|string
|
||||
*/
|
||||
public static function PROPERCASE($mixedCaseString)
|
||||
{
|
||||
|
|
@ -420,7 +420,7 @@ class TextData
|
|||
* @param mixed $ignoreEmpty
|
||||
* @param mixed $args
|
||||
*
|
||||
* @return string
|
||||
* @return array|string
|
||||
*/
|
||||
public static function TEXTJOIN($delimiter, $ignoreEmpty, ...$args)
|
||||
{
|
||||
|
|
@ -436,10 +436,10 @@ class TextData
|
|||
*
|
||||
* @see Use the builtinREPT() method in the TextData\Concatenate class instead
|
||||
*
|
||||
* @param string $str Should be numeric
|
||||
* @param array|string $str Should be numeric
|
||||
* @param mixed $number Should be int
|
||||
*
|
||||
* @return string
|
||||
* @return array|string
|
||||
*/
|
||||
public static function builtinREPT($str, $number)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2,20 +2,32 @@
|
|||
|
||||
namespace PhpOffice\PhpSpreadsheet\Calculation\TextData;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\ArrayEnabled;
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
|
||||
use PhpOffice\PhpSpreadsheet\Shared\StringHelper;
|
||||
|
||||
class CaseConvert
|
||||
{
|
||||
use ArrayEnabled;
|
||||
|
||||
/**
|
||||
* LOWERCASE.
|
||||
*
|
||||
* Converts a string value to upper case.
|
||||
*
|
||||
* @param mixed $mixedCaseValue The string value to convert to lower case
|
||||
* Or can be an array of values
|
||||
*
|
||||
* @return array|string
|
||||
* If an array of values is passed as the argument, then the returned result will also be an array
|
||||
* with the same dimensions
|
||||
*/
|
||||
public static function lower($mixedCaseValue): string
|
||||
public static function lower($mixedCaseValue)
|
||||
{
|
||||
if (is_array($mixedCaseValue)) {
|
||||
return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $mixedCaseValue);
|
||||
}
|
||||
|
||||
$mixedCaseValue = Functions::flattenSingleValue($mixedCaseValue);
|
||||
$mixedCaseValue = Helpers::extractString($mixedCaseValue);
|
||||
|
||||
|
|
@ -28,9 +40,18 @@ class CaseConvert
|
|||
* Converts a string value to upper case.
|
||||
*
|
||||
* @param mixed $mixedCaseValue The string value to convert to upper case
|
||||
* Or can be an array of values
|
||||
*
|
||||
* @return array|string
|
||||
* If an array of values is passed as the argument, then the returned result will also be an array
|
||||
* with the same dimensions
|
||||
*/
|
||||
public static function upper($mixedCaseValue): string
|
||||
public static function upper($mixedCaseValue)
|
||||
{
|
||||
if (is_array($mixedCaseValue)) {
|
||||
return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $mixedCaseValue);
|
||||
}
|
||||
|
||||
$mixedCaseValue = Functions::flattenSingleValue($mixedCaseValue);
|
||||
$mixedCaseValue = Helpers::extractString($mixedCaseValue);
|
||||
|
||||
|
|
@ -43,9 +64,18 @@ class CaseConvert
|
|||
* Converts a string value to proper or title case.
|
||||
*
|
||||
* @param mixed $mixedCaseValue The string value to convert to title case
|
||||
* Or can be an array of values
|
||||
*
|
||||
* @return array|string
|
||||
* If an array of values is passed as the argument, then the returned result will also be an array
|
||||
* with the same dimensions
|
||||
*/
|
||||
public static function proper($mixedCaseValue): string
|
||||
public static function proper($mixedCaseValue)
|
||||
{
|
||||
if (is_array($mixedCaseValue)) {
|
||||
return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $mixedCaseValue);
|
||||
}
|
||||
|
||||
$mixedCaseValue = Functions::flattenSingleValue($mixedCaseValue);
|
||||
$mixedCaseValue = Helpers::extractString($mixedCaseValue);
|
||||
|
||||
|
|
|
|||
|
|
@ -2,17 +2,29 @@
|
|||
|
||||
namespace PhpOffice\PhpSpreadsheet\Calculation\TextData;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\ArrayEnabled;
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
|
||||
|
||||
class CharacterConvert
|
||||
{
|
||||
use ArrayEnabled;
|
||||
|
||||
/**
|
||||
* CHAR.
|
||||
*
|
||||
* @param mixed $character Integer Value to convert to its character representation
|
||||
* Or can be an array of values
|
||||
*
|
||||
* @return array|string The character string
|
||||
* If an array of values is passed as the argument, then the returned result will also be an array
|
||||
* with the same dimensions
|
||||
*/
|
||||
public static function character($character): string
|
||||
public static function character($character)
|
||||
{
|
||||
if (is_array($character)) {
|
||||
return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $character);
|
||||
}
|
||||
|
||||
$character = Helpers::validateInt($character);
|
||||
$min = Functions::getCompatibilityMode() === Functions::COMPATIBILITY_OPENOFFICE ? 0 : 1;
|
||||
if ($character < $min || $character > 255) {
|
||||
|
|
@ -27,11 +39,18 @@ class CharacterConvert
|
|||
* CODE.
|
||||
*
|
||||
* @param mixed $characters String character to convert to its ASCII value
|
||||
* Or can be an array of values
|
||||
*
|
||||
* @return int|string A string if arguments are invalid
|
||||
* @return array|int|string A string if arguments are invalid
|
||||
* If an array of values is passed as the argument, then the returned result will also be an array
|
||||
* with the same dimensions
|
||||
*/
|
||||
public static function code($characters)
|
||||
{
|
||||
if (is_array($characters)) {
|
||||
return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $characters);
|
||||
}
|
||||
|
||||
$characters = Helpers::extractString($characters);
|
||||
if ($characters === '') {
|
||||
return Functions::VALUE();
|
||||
|
|
|
|||
|
|
@ -2,10 +2,13 @@
|
|||
|
||||
namespace PhpOffice\PhpSpreadsheet\Calculation\TextData;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\ArrayEnabled;
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
|
||||
|
||||
class Concatenate
|
||||
{
|
||||
use ArrayEnabled;
|
||||
|
||||
/**
|
||||
* CONCATENATE.
|
||||
*
|
||||
|
|
@ -28,12 +31,28 @@ class Concatenate
|
|||
/**
|
||||
* TEXTJOIN.
|
||||
*
|
||||
* @param mixed $delimiter
|
||||
* @param mixed $ignoreEmpty
|
||||
* @param mixed $args
|
||||
* @param mixed $delimiter The delimter to use between the joined arguments
|
||||
* Or can be an array of values
|
||||
* @param mixed $ignoreEmpty true/false Flag indicating whether empty arguments should be skipped
|
||||
* Or can be an array of values
|
||||
* @param mixed $args The values to join
|
||||
*
|
||||
* @return array|string The joined string
|
||||
* If an array of values is passed for the $delimiter or $ignoreEmpty arguments, then the returned result
|
||||
* will also be an array with matching dimensions
|
||||
*/
|
||||
public static function TEXTJOIN($delimiter, $ignoreEmpty, ...$args): string
|
||||
public static function TEXTJOIN($delimiter, $ignoreEmpty, ...$args)
|
||||
{
|
||||
if (is_array($delimiter) || is_array($ignoreEmpty)) {
|
||||
return self::evaluateArrayArgumentsSubset(
|
||||
[self::class, __FUNCTION__],
|
||||
2,
|
||||
$delimiter,
|
||||
$ignoreEmpty,
|
||||
...$args
|
||||
);
|
||||
}
|
||||
|
||||
$delimiter = Functions::flattenSingleValue($delimiter);
|
||||
$ignoreEmpty = Functions::flattenSingleValue($ignoreEmpty);
|
||||
// Loop through arguments
|
||||
|
|
@ -55,10 +74,20 @@ class Concatenate
|
|||
* Returns the result of builtin function round after validating args.
|
||||
*
|
||||
* @param mixed $stringValue The value to repeat
|
||||
* Or can be an array of values
|
||||
* @param mixed $repeatCount The number of times the string value should be repeated
|
||||
* Or can be an array of values
|
||||
*
|
||||
* @return array|string The repeated string
|
||||
* If an array of values is passed for the $stringValue or $repeatCount arguments, then the returned result
|
||||
* will also be an array with matching dimensions
|
||||
*/
|
||||
public static function builtinREPT($stringValue, $repeatCount): string
|
||||
public static function builtinREPT($stringValue, $repeatCount)
|
||||
{
|
||||
if (is_array($stringValue) || is_array($repeatCount)) {
|
||||
return self::evaluateArrayArguments([self::class, __FUNCTION__], $stringValue, $repeatCount);
|
||||
}
|
||||
|
||||
$repeatCount = Functions::flattenSingleValue($repeatCount);
|
||||
$stringValue = Helpers::extractString($stringValue);
|
||||
|
||||
|
|
|
|||
|
|
@ -2,18 +2,31 @@
|
|||
|
||||
namespace PhpOffice\PhpSpreadsheet\Calculation\TextData;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\ArrayEnabled;
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Exception as CalcExp;
|
||||
|
||||
class Extract
|
||||
{
|
||||
use ArrayEnabled;
|
||||
|
||||
/**
|
||||
* LEFT.
|
||||
*
|
||||
* @param mixed $value String value from which to extract characters
|
||||
* Or can be an array of values
|
||||
* @param mixed $chars The number of characters to extract (as an integer)
|
||||
* Or can be an array of values
|
||||
*
|
||||
* @return array|string The joined string
|
||||
* If an array of values is passed for the $value or $chars arguments, then the returned result
|
||||
* will also be an array with matching dimensions
|
||||
*/
|
||||
public static function left($value, $chars = 1): string
|
||||
public static function left($value, $chars = 1)
|
||||
{
|
||||
if (is_array($value) || is_array($chars)) {
|
||||
return self::evaluateArrayArguments([self::class, __FUNCTION__], $value, $chars);
|
||||
}
|
||||
|
||||
try {
|
||||
$value = Helpers::extractString($value);
|
||||
$chars = Helpers::extractInt($chars, 0, 1);
|
||||
|
|
@ -28,11 +41,22 @@ class Extract
|
|||
* MID.
|
||||
*
|
||||
* @param mixed $value String value from which to extract characters
|
||||
* Or can be an array of values
|
||||
* @param mixed $start Integer offset of the first character that we want to extract
|
||||
* Or can be an array of values
|
||||
* @param mixed $chars The number of characters to extract (as an integer)
|
||||
* Or can be an array of values
|
||||
*
|
||||
* @return array|string The joined string
|
||||
* If an array of values is passed for the $value, $start or $chars arguments, then the returned result
|
||||
* will also be an array with matching dimensions
|
||||
*/
|
||||
public static function mid($value, $start, $chars): string
|
||||
public static function mid($value, $start, $chars)
|
||||
{
|
||||
if (is_array($value) || is_array($start) || is_array($chars)) {
|
||||
return self::evaluateArrayArguments([self::class, __FUNCTION__], $value, $start, $chars);
|
||||
}
|
||||
|
||||
try {
|
||||
$value = Helpers::extractString($value);
|
||||
$start = Helpers::extractInt($start, 1);
|
||||
|
|
@ -48,10 +72,20 @@ class Extract
|
|||
* RIGHT.
|
||||
*
|
||||
* @param mixed $value String value from which to extract characters
|
||||
* Or can be an array of values
|
||||
* @param mixed $chars The number of characters to extract (as an integer)
|
||||
* Or can be an array of values
|
||||
*
|
||||
* @return array|string The joined string
|
||||
* If an array of values is passed for the $value or $chars arguments, then the returned result
|
||||
* will also be an array with matching dimensions
|
||||
*/
|
||||
public static function right($value, $chars = 1): string
|
||||
public static function right($value, $chars = 1)
|
||||
{
|
||||
if (is_array($value) || is_array($chars)) {
|
||||
return self::evaluateArrayArguments([self::class, __FUNCTION__], $value, $chars);
|
||||
}
|
||||
|
||||
try {
|
||||
$value = Helpers::extractString($value);
|
||||
$chars = Helpers::extractInt($chars, 0, 1);
|
||||
|
|
|
|||
|
|
@ -146,14 +146,14 @@ class Format
|
|||
Functions::setReturnDateType(Functions::RETURNDATE_EXCEL);
|
||||
|
||||
if (strpos($value, ':') !== false) {
|
||||
$timeValue = DateTimeExcel\TimeValue::fromString($value);
|
||||
$timeValue = Functions::scalar(DateTimeExcel\TimeValue::fromString($value));
|
||||
if ($timeValue !== Functions::VALUE()) {
|
||||
Functions::setReturnDateType($dateSetting);
|
||||
|
||||
return $timeValue;
|
||||
}
|
||||
}
|
||||
$dateValue = DateTimeExcel\DateValue::fromString($value);
|
||||
$dateValue = Functions::scalar(DateTimeExcel\DateValue::fromString($value));
|
||||
if ($dateValue !== Functions::VALUE()) {
|
||||
Functions::setReturnDateType($dateSetting);
|
||||
|
||||
|
|
|
|||
|
|
@ -2,23 +2,35 @@
|
|||
|
||||
namespace PhpOffice\PhpSpreadsheet\Calculation\TextData;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\ArrayEnabled;
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Exception as CalcExp;
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
|
||||
use PhpOffice\PhpSpreadsheet\Shared\StringHelper;
|
||||
|
||||
class Search
|
||||
{
|
||||
use ArrayEnabled;
|
||||
|
||||
/**
|
||||
* FIND (case sensitive search).
|
||||
*
|
||||
* @param mixed $needle The string to look for
|
||||
* Or can be an array of values
|
||||
* @param mixed $haystack The string in which to look
|
||||
* Or can be an array of values
|
||||
* @param mixed $offset Integer offset within $haystack to start searching from
|
||||
* Or can be an array of values
|
||||
*
|
||||
* @return int|string
|
||||
* @return array|int|string The offset where the first occurrence of needle was found in the haystack
|
||||
* If an array of values is passed for the $value or $chars arguments, then the returned result
|
||||
* will also be an array with matching dimensions
|
||||
*/
|
||||
public static function sensitive($needle, $haystack, $offset = 1)
|
||||
{
|
||||
if (is_array($needle) || is_array($haystack) || is_array($offset)) {
|
||||
return self::evaluateArrayArguments([self::class, __FUNCTION__], $needle, $haystack, $offset);
|
||||
}
|
||||
|
||||
try {
|
||||
$needle = Helpers::extractString($needle);
|
||||
$haystack = Helpers::extractString($haystack);
|
||||
|
|
@ -45,13 +57,22 @@ class Search
|
|||
* SEARCH (case insensitive search).
|
||||
*
|
||||
* @param mixed $needle The string to look for
|
||||
* Or can be an array of values
|
||||
* @param mixed $haystack The string in which to look
|
||||
* Or can be an array of values
|
||||
* @param mixed $offset Integer offset within $haystack to start searching from
|
||||
* Or can be an array of values
|
||||
*
|
||||
* @return int|string
|
||||
* @return array|int|string The offset where the first occurrence of needle was found in the haystack
|
||||
* If an array of values is passed for the $value or $chars arguments, then the returned result
|
||||
* will also be an array with matching dimensions
|
||||
*/
|
||||
public static function insensitive($needle, $haystack, $offset = 1)
|
||||
{
|
||||
if (is_array($needle) || is_array($haystack) || is_array($offset)) {
|
||||
return self::evaluateArrayArguments([self::class, __FUNCTION__], $needle, $haystack, $offset);
|
||||
}
|
||||
|
||||
try {
|
||||
$needle = Helpers::extractString($needle);
|
||||
$haystack = Helpers::extractString($haystack);
|
||||
|
|
|
|||
|
|
@ -2,17 +2,28 @@
|
|||
|
||||
namespace PhpOffice\PhpSpreadsheet\Calculation\TextData;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\ArrayEnabled;
|
||||
|
||||
class Trim
|
||||
{
|
||||
use ArrayEnabled;
|
||||
|
||||
/**
|
||||
* CLEAN.
|
||||
*
|
||||
* @param mixed $stringValue String Value to check
|
||||
* Or can be an array of values
|
||||
*
|
||||
* @return null|string
|
||||
* @return null|array|string
|
||||
* If an array of values is passed as the argument, then the returned result will also be an array
|
||||
* with the same dimensions
|
||||
*/
|
||||
public static function nonPrintable($stringValue = '')
|
||||
{
|
||||
if (is_array($stringValue)) {
|
||||
return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $stringValue);
|
||||
}
|
||||
|
||||
$stringValue = Helpers::extractString($stringValue);
|
||||
|
||||
return preg_replace('/[\\x00-\\x1f]/', '', "$stringValue");
|
||||
|
|
@ -22,11 +33,18 @@ class Trim
|
|||
* TRIM.
|
||||
*
|
||||
* @param mixed $stringValue String Value to check
|
||||
* Or can be an array of values
|
||||
*
|
||||
* @return string
|
||||
* @return array|string
|
||||
* If an array of values is passed as the argument, then the returned result will also be an array
|
||||
* with the same dimensions
|
||||
*/
|
||||
public static function spaces($stringValue = '')
|
||||
{
|
||||
if (is_array($stringValue)) {
|
||||
return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $stringValue);
|
||||
}
|
||||
|
||||
$stringValue = Helpers::extractString($stringValue);
|
||||
|
||||
return trim(preg_replace('/ +/', ' ', trim("$stringValue", ' ')) ?? '', ' ');
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Financial;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Calculation;
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Financial;
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
|
@ -28,4 +29,52 @@ class DollarDeTest extends TestCase
|
|||
{
|
||||
return require 'tests/data/Calculation/Financial/DOLLARDE.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerDollarDeArray
|
||||
*/
|
||||
public function testDollarDeArray(array $expectedResult, string $argument1, string $argument2): void
|
||||
{
|
||||
$calculation = Calculation::getInstance();
|
||||
|
||||
$formula = "=DollarDe({$argument1},{$argument2})";
|
||||
$result = $calculation->_calculateFormulaValue($formula);
|
||||
self::assertEqualsWithDelta($expectedResult, $result, 1.0e-12);
|
||||
}
|
||||
|
||||
public function providerDollarDeArray(): array
|
||||
{
|
||||
return [
|
||||
'first argument row vector' => [
|
||||
[[1.125, 2.0625, -12.625, 3.5]],
|
||||
'{1.02, 2.01, -12.1, 1.4}',
|
||||
'16',
|
||||
],
|
||||
'first argument column vector' => [
|
||||
[[1.0625], [2.03125], [-12.3125], [2.25]],
|
||||
'{1.02; 2.01; -12.1; 1.4}',
|
||||
'32',
|
||||
],
|
||||
'first argument matrix' => [
|
||||
[[1.05, 2.25], [-12.5, 2.0]],
|
||||
'{1.02, 2.1; -12.2, 1.4}',
|
||||
'4',
|
||||
],
|
||||
'second argument row vector' => [
|
||||
[[4.25, 3.625, 6.125, 4.5625]],
|
||||
'3.5',
|
||||
'{4, 8, 16, 32}',
|
||||
],
|
||||
'second argument column vector' => [
|
||||
[[5.5], [4.25], [3.625], [6.125]],
|
||||
'3.5',
|
||||
'{2; 4; 8; 16}',
|
||||
],
|
||||
'second argument matrix' => [
|
||||
[[-4.875, -3.9375], [-9.25, -7.6875]],
|
||||
'-3.75',
|
||||
'{4, 8; 12, 16}',
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\TextData;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Calculation;
|
||||
|
||||
class CharTest extends AllSetupTeardown
|
||||
{
|
||||
/**
|
||||
|
|
@ -28,4 +30,25 @@ class CharTest extends AllSetupTeardown
|
|||
{
|
||||
return require 'tests/data/Calculation/TextData/CHAR.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerCharArray
|
||||
*/
|
||||
public function testCharArray(array $expectedResult, string $array): void
|
||||
{
|
||||
$calculation = Calculation::getInstance();
|
||||
|
||||
$formula = "=CHAR({$array})";
|
||||
$result = $calculation->_calculateFormulaValue($formula);
|
||||
self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14);
|
||||
}
|
||||
|
||||
public function providerCharArray(): array
|
||||
{
|
||||
return [
|
||||
'row vector' => [[['P', 'H', 'P']], '{80, 72, 80}'],
|
||||
'column vector' => [[['P'], ['H'], ['P']], '{80; 72; 80}'],
|
||||
'matrix' => [[['Y', 'o'], ['l', 'o']], '{89, 111; 108, 111}'],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\TextData;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Calculation;
|
||||
|
||||
class CleanTest extends AllSetupTeardown
|
||||
{
|
||||
/**
|
||||
|
|
@ -28,4 +30,25 @@ class CleanTest extends AllSetupTeardown
|
|||
{
|
||||
return require 'tests/data/Calculation/TextData/CLEAN.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerCleanArray
|
||||
*/
|
||||
public function testCleanArray(array $expectedResult, string $array): void
|
||||
{
|
||||
$calculation = Calculation::getInstance();
|
||||
|
||||
$formula = "=CLEAN({$array})";
|
||||
$result = $calculation->_calculateFormulaValue($formula);
|
||||
self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14);
|
||||
}
|
||||
|
||||
public function providerCleanArray(): array
|
||||
{
|
||||
return [
|
||||
'row vector' => [[['PHP', 'MS Excel', 'Open/Libre Office']], '{"PHP", "MS Excel", "Open/Libre Office"}'],
|
||||
'column vector' => [[['PHP'], ['MS Excel'], ['Open/Libre Office']], '{"PHP"; "MS Excel"; "Open/Libre Office"}'],
|
||||
'matrix' => [[['PHP', 'MS Excel'], ['PhpSpreadsheet', 'Open/Libre Office']], '{"PHP", "MS Excel"; "PhpSpreadsheet", "Open/Libre Office"}'],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\TextData;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Calculation;
|
||||
|
||||
class CodeTest extends AllSetupTeardown
|
||||
{
|
||||
/**
|
||||
|
|
@ -28,4 +30,25 @@ class CodeTest extends AllSetupTeardown
|
|||
{
|
||||
return require 'tests/data/Calculation/TextData/CODE.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerCodeArray
|
||||
*/
|
||||
public function testCodeArray(array $expectedResult, string $array): void
|
||||
{
|
||||
$calculation = Calculation::getInstance();
|
||||
|
||||
$formula = "=CODE({$array})";
|
||||
$result = $calculation->_calculateFormulaValue($formula);
|
||||
self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14);
|
||||
}
|
||||
|
||||
public function providerCodeArray(): array
|
||||
{
|
||||
return [
|
||||
'row vector' => [[[80, 72, 80]], '{"P", "H", "P"}'],
|
||||
'column vector' => [[[80], [72], [80]], '{"P"; "H"; "P"}'],
|
||||
'matrix' => [[[89, 111], [108, 111]], '{"Y", "o"; "l", "o"}'],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\TextData;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Calculation;
|
||||
|
||||
class FindTest extends AllSetupTeardown
|
||||
{
|
||||
/**
|
||||
|
|
@ -39,4 +41,25 @@ class FindTest extends AllSetupTeardown
|
|||
{
|
||||
return require 'tests/data/Calculation/TextData/FIND.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerFindArray
|
||||
*/
|
||||
public function testFindArray(array $expectedResult, string $argument1, string $argument2): void
|
||||
{
|
||||
$calculation = Calculation::getInstance();
|
||||
|
||||
$formula = "=FIND({$argument1}, {$argument2})";
|
||||
$result = $calculation->_calculateFormulaValue($formula);
|
||||
self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14);
|
||||
}
|
||||
|
||||
public function providerFindArray(): array
|
||||
{
|
||||
return [
|
||||
'row vector #1' => [[[3, 4, '#VALUE!']], '"l"', '{"Hello", "World", "PhpSpreadsheet"}'],
|
||||
'column vector #1' => [[[3], [4], ['#VALUE!']], '"l"', '{"Hello"; "World"; "PhpSpreadsheet"}'],
|
||||
'matrix #1' => [[[3, 4], ['#VALUE!', 5]], '"l"', '{"Hello", "World"; "PhpSpreadsheet", "Excel"}'],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\TextData;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Calculation;
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
|
||||
use PhpOffice\PhpSpreadsheet\Settings;
|
||||
|
||||
|
|
@ -180,4 +181,26 @@ class LeftTest extends AllSetupTeardown
|
|||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerLeftArray
|
||||
*/
|
||||
public function testLeftArray(array $expectedResult, string $argument1, string $argument2): void
|
||||
{
|
||||
$calculation = Calculation::getInstance();
|
||||
|
||||
$formula = "=LEFT({$argument1}, {$argument2})";
|
||||
$result = $calculation->_calculateFormulaValue($formula);
|
||||
self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14);
|
||||
}
|
||||
|
||||
public function providerLeftArray(): array
|
||||
{
|
||||
return [
|
||||
'row vector #1' => [[['Hel', 'Wor', 'Php']], '{"Hello", "World", "PhpSpreadsheet"}', '3'],
|
||||
'column vector #1' => [[['Hel'], ['Wor'], ['Php']], '{"Hello"; "World"; "PhpSpreadsheet"}', '3'],
|
||||
'matrix #1' => [[['Hel', 'Wor'], ['Php', 'Exc']], '{"Hello", "World"; "PhpSpreadsheet", "Excel"}', '3'],
|
||||
'column vector #2' => [[['Php'], ['PhpSp']], '"PhpSpreadsheet"', '{3; 5}'],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\TextData;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Calculation;
|
||||
use PhpOffice\PhpSpreadsheet\Settings;
|
||||
|
||||
class LowerTest extends AllSetupTeardown
|
||||
|
|
@ -64,4 +65,25 @@ class LowerTest extends AllSetupTeardown
|
|||
['ложь', 'bg', false],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerLowerArray
|
||||
*/
|
||||
public function testLowerArray(array $expectedResult, string $array): void
|
||||
{
|
||||
$calculation = Calculation::getInstance();
|
||||
|
||||
$formula = "=LOWER({$array})";
|
||||
$result = $calculation->_calculateFormulaValue($formula);
|
||||
self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14);
|
||||
}
|
||||
|
||||
public function providerLowerArray(): array
|
||||
{
|
||||
return [
|
||||
'row vector' => [[["let's", 'all change', 'case']], '{"lEt\'S", "aLl chAngE", "cAsE"}'],
|
||||
'column vector' => [[["let's"], ['all change'], ['case']], '{"lEt\'S"; "aLl chAngE"; "cAsE"}'],
|
||||
'matrix' => [[['build all', 'your workbooks'], ['with', 'phpspreadsheet']], '{"bUIld aLL", "yOUr WOrkBOOks"; "wiTH", "PhpSpreadsheet"}'],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\TextData;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Calculation;
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
|
||||
use PhpOffice\PhpSpreadsheet\Settings;
|
||||
|
||||
|
|
@ -202,4 +203,24 @@ class MidTest extends AllSetupTeardown
|
|||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerMidArray
|
||||
*/
|
||||
public function testMidArray(array $expectedResult, string $argument1, string $argument2, string $argument3): void
|
||||
{
|
||||
$calculation = Calculation::getInstance();
|
||||
|
||||
$formula = "=MID({$argument1}, {$argument2}, {$argument3})";
|
||||
$result = $calculation->_calculateFormulaValue($formula);
|
||||
self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14);
|
||||
}
|
||||
|
||||
public function providerMidArray(): array
|
||||
{
|
||||
return [
|
||||
'row vector #1' => [[['lo Wor', 'Spread']], '{"Hello World", "PhpSpreadsheet"}', '4', '6'],
|
||||
'column vector #1' => [[[' Wor'], ['read']], '{"Hello World"; "PhpSpreadsheet"}', '6', '4'],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\TextData;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Calculation;
|
||||
use PhpOffice\PhpSpreadsheet\Settings;
|
||||
|
||||
class ProperTest extends AllSetupTeardown
|
||||
|
|
@ -64,4 +65,25 @@ class ProperTest extends AllSetupTeardown
|
|||
['Ложь', 'bg', false],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerProperArray
|
||||
*/
|
||||
public function testProperArray(array $expectedResult, string $array): void
|
||||
{
|
||||
$calculation = Calculation::getInstance();
|
||||
|
||||
$formula = "=PROPER({$array})";
|
||||
$result = $calculation->_calculateFormulaValue($formula);
|
||||
self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14);
|
||||
}
|
||||
|
||||
public function providerProperArray(): array
|
||||
{
|
||||
return [
|
||||
'row vector' => [[["Let's", 'All Change', 'Case']], '{"lEt\'S", "aLl chAngE", "cAsE"}'],
|
||||
'column vector' => [[["Let's"], ['All Change'], ['Case']], '{"lEt\'S"; "aLl chAngE"; "cAsE"}'],
|
||||
'matrix' => [[['Build All', 'Your Workbooks'], ['With', 'Phpspreadsheet']], '{"bUIld aLL", "yOUr WOrkBOOks"; "wiTH", "PhpSpreadsheet"}'],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\TextData;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Calculation;
|
||||
|
||||
class ReptTest extends AllSetupTeardown
|
||||
{
|
||||
/**
|
||||
|
|
@ -33,4 +35,26 @@ class ReptTest extends AllSetupTeardown
|
|||
{
|
||||
return require 'tests/data/Calculation/TextData/REPT.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerReptArray
|
||||
*/
|
||||
public function testReptArray(array $expectedResult, string $argument1, string $argument2): void
|
||||
{
|
||||
$calculation = Calculation::getInstance();
|
||||
|
||||
$formula = "=REPT({$argument1}, {$argument2})";
|
||||
$result = $calculation->_calculateFormulaValue($formula);
|
||||
self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14);
|
||||
}
|
||||
|
||||
public function providerReptArray(): array
|
||||
{
|
||||
return [
|
||||
'row vector #1' => [[['PHPPHPPHP', 'HAHAHA', 'HOHOHO']], '{"PHP", "HA", "HO"}', '3'],
|
||||
'column vector #1' => [[['PHPPHPPHP'], ['HAHAHA'], ['HOHOHO']], '{"PHP"; "HA"; "HO"}', '3'],
|
||||
'matrix #1' => [[['PHPPHP', '❤️🐘💚❤️🐘💚'], ['HAHA', 'HOHO']], '{"PHP", "❤️🐘💚"; "HA", "HO"}', '2'],
|
||||
'row vector #2' => [[[' PHP PHP PHP ', ' PHP PHP ']], '" PHP "', '{3, 2}'],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\TextData;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Calculation;
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
|
||||
use PhpOffice\PhpSpreadsheet\Settings;
|
||||
|
||||
|
|
@ -180,4 +181,26 @@ class RightTest extends AllSetupTeardown
|
|||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerRightArray
|
||||
*/
|
||||
public function testRightArray(array $expectedResult, string $argument1, string $argument2): void
|
||||
{
|
||||
$calculation = Calculation::getInstance();
|
||||
|
||||
$formula = "=RIGHT({$argument1}, {$argument2})";
|
||||
$result = $calculation->_calculateFormulaValue($formula);
|
||||
self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14);
|
||||
}
|
||||
|
||||
public function providerRightArray(): array
|
||||
{
|
||||
return [
|
||||
'row vector #1' => [[['llo', 'rld', 'eet']], '{"Hello", "World", "PhpSpreadsheet"}', '3'],
|
||||
'column vector #1' => [[['llo'], ['rld'], ['eet']], '{"Hello"; "World"; "PhpSpreadsheet"}', '3'],
|
||||
'matrix #1' => [[['llo', 'rld'], ['eet', 'cel']], '{"Hello", "World"; "PhpSpreadsheet", "Excel"}', '3'],
|
||||
'column vector #2' => [[['eet'], ['sheet']], '"PhpSpreadsheet"', '{3; 5}'],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\TextData;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Calculation;
|
||||
|
||||
class SearchTest extends AllSetupTeardown
|
||||
{
|
||||
/**
|
||||
|
|
@ -39,4 +41,25 @@ class SearchTest extends AllSetupTeardown
|
|||
{
|
||||
return require 'tests/data/Calculation/TextData/SEARCH.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerSearchArray
|
||||
*/
|
||||
public function testSearchArray(array $expectedResult, string $argument1, string $argument2): void
|
||||
{
|
||||
$calculation = Calculation::getInstance();
|
||||
|
||||
$formula = "=SEARCH({$argument1}, {$argument2})";
|
||||
$result = $calculation->_calculateFormulaValue($formula);
|
||||
self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14);
|
||||
}
|
||||
|
||||
public function providerSearchArray(): array
|
||||
{
|
||||
return [
|
||||
'row vector #1' => [[[3, 4, '#VALUE!']], '"L"', '{"Hello", "World", "PhpSpreadsheet"}'],
|
||||
'column vector #1' => [[[3], [4], ['#VALUE!']], '"L"', '{"Hello"; "World"; "PhpSpreadsheet"}'],
|
||||
'matrix #1' => [[[3, 4], ['#VALUE!', 5]], '"L"', '{"Hello", "World"; "PhpSpreadsheet", "Excel"}'],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\TextData;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Calculation;
|
||||
|
||||
class TextJoinTest extends AllSetupTeardown
|
||||
{
|
||||
/**
|
||||
|
|
@ -32,4 +34,25 @@ class TextJoinTest extends AllSetupTeardown
|
|||
{
|
||||
return require 'tests/data/Calculation/TextData/TEXTJOIN.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerTextjoinArray
|
||||
*/
|
||||
public function testTextjoinArray(array $expectedResult, string $delimiter, string $blanks, string $texts): void
|
||||
{
|
||||
$calculation = Calculation::getInstance();
|
||||
|
||||
$formula = "=TEXTJOIN({$delimiter}, {$blanks}, {$texts})";
|
||||
$result = $calculation->_calculateFormulaValue($formula);
|
||||
self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14);
|
||||
}
|
||||
|
||||
public function providerTextjoinArray(): array
|
||||
{
|
||||
return [
|
||||
'row vector #1' => [[['AB,CD,EF', 'AB;CD;EF']], '{",", ";"}', 'FALSE', '"AB", "CD", "EF"'],
|
||||
'column vector #1' => [[['AB--CD--EF'], ['AB|CD|EF']], '{"--"; "|"}', 'FALSE', '"AB", "CD", "EF"'],
|
||||
'matrix #1' => [[['AB,CD,EF', 'AB;CD;EF'], ['AB-CD-EF', 'AB|CD|EF']], '{",", ";"; "-", "|"}', 'FALSE', '"AB", "CD", "EF"'],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\TextData;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Calculation;
|
||||
|
||||
class TrimTest extends AllSetupTeardown
|
||||
{
|
||||
/**
|
||||
|
|
@ -28,4 +30,25 @@ class TrimTest extends AllSetupTeardown
|
|||
{
|
||||
return require 'tests/data/Calculation/TextData/TRIM.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerTrimArray
|
||||
*/
|
||||
public function testTrimArray(array $expectedResult, string $array): void
|
||||
{
|
||||
$calculation = Calculation::getInstance();
|
||||
|
||||
$formula = "=TRIM({$array})";
|
||||
$result = $calculation->_calculateFormulaValue($formula);
|
||||
self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14);
|
||||
}
|
||||
|
||||
public function providerTrimArray(): array
|
||||
{
|
||||
return [
|
||||
'row vector' => [[['PHP', 'MS Excel', 'Open/Libre Office']], '{" PHP ", " MS Excel ", " Open/Libre Office "}'],
|
||||
'column vector' => [[['PHP'], ['MS Excel'], ['Open/Libre Office']], '{" PHP "; " MS Excel "; " Open/Libre Office "}'],
|
||||
'matrix' => [[['PHP', 'MS Excel'], ['PhpSpreadsheet', 'Open/Libre Office']], '{" PHP ", " MS Excel "; " PhpSpreadsheet ", " Open/Libre Office "}'],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\TextData;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Calculation;
|
||||
use PhpOffice\PhpSpreadsheet\Settings;
|
||||
|
||||
class UpperTest extends AllSetupTeardown
|
||||
|
|
@ -64,4 +65,25 @@ class UpperTest extends AllSetupTeardown
|
|||
['ЛОЖЬ', 'bg', false],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerUpperArray
|
||||
*/
|
||||
public function testUpperArray(array $expectedResult, string $array): void
|
||||
{
|
||||
$calculation = Calculation::getInstance();
|
||||
|
||||
$formula = "=UPPER({$array})";
|
||||
$result = $calculation->_calculateFormulaValue($formula);
|
||||
self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14);
|
||||
}
|
||||
|
||||
public function providerUpperArray(): array
|
||||
{
|
||||
return [
|
||||
'row vector' => [[["LET'S", 'ALL CHANGE', 'CASE']], '{"lEt\'S", "aLl chAngE", "cAsE"}'],
|
||||
'column vector' => [[["LET'S"], ['ALL CHANGE'], ['CASE']], '{"lEt\'S"; "aLl chAngE"; "cAsE"}'],
|
||||
'matrix' => [[['BUILD ALL', 'YOUR WORKBOOKS'], ['WITH', 'PHPSPREADSHEET']], '{"bUIld aLL", "yOUr WOrkBOOks"; "wiTH", "PhpSpreadsheet"}'],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue