| 1441 |
ariadna |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
namespace PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
|
|
4 |
|
|
|
5 |
use PhpOffice\PhpSpreadsheet\Shared\StringHelper;
|
|
|
6 |
|
|
|
7 |
abstract class BaseFormatter
|
|
|
8 |
{
|
|
|
9 |
protected static function stripQuotes(string $format): string
|
|
|
10 |
{
|
|
|
11 |
// Some non-number strings are quoted, so we'll get rid of the quotes, likewise any positional * symbols
|
|
|
12 |
return str_replace(['"', '*'], '', $format);
|
|
|
13 |
}
|
|
|
14 |
|
|
|
15 |
protected static function adjustSeparators(string $value): string
|
|
|
16 |
{
|
|
|
17 |
$thousandsSeparator = StringHelper::getThousandsSeparator();
|
|
|
18 |
$decimalSeparator = StringHelper::getDecimalSeparator();
|
|
|
19 |
if ($thousandsSeparator !== ',' || $decimalSeparator !== '.') {
|
|
|
20 |
$value = str_replace(['.', ',', "\u{fffd}"], ["\u{fffd}", $thousandsSeparator, $decimalSeparator], $value);
|
|
|
21 |
}
|
|
|
22 |
|
|
|
23 |
return $value;
|
|
|
24 |
}
|
|
|
25 |
}
|