Resolve phpcs issues
This commit is contained in:
parent
60ade80c0f
commit
91af5bbc4f
|
|
@ -74,35 +74,33 @@ class AddressHelper
|
|||
int $currentColumnNumber = 1
|
||||
): string {
|
||||
if (substr($formula, 0, 3) == 'of:') {
|
||||
// We have a SpreasheetML Formula
|
||||
// We have an old-style SpreadsheetML Formula
|
||||
return self::convertSpreadsheetMLFormula($formula);
|
||||
} else {
|
||||
// Convert R1C1 style references to A1 style references (but only when not quoted)
|
||||
$temp = explode('"', $formula);
|
||||
$key = false;
|
||||
foreach ($temp as &$value) {
|
||||
// Only replace in alternate array entries (i.e. non-quoted blocks)
|
||||
if ($key = !$key) {
|
||||
preg_match_all(self::R1C1_COORDINATE_REGEX, $value, $cellReferences, PREG_SET_ORDER + PREG_OFFSET_CAPTURE);
|
||||
// Reverse the matches array, otherwise all our offsets will become incorrect if we modify our way
|
||||
// through the formula from left to right. Reversing means that we work right to left.through
|
||||
// the formula
|
||||
$cellReferences = array_reverse($cellReferences);
|
||||
// Loop through each R1C1 style reference in turn, converting it to its A1 style equivalent,
|
||||
// then modify the formula to use that new reference
|
||||
foreach ($cellReferences as $cellReference) {
|
||||
$A1CellReference = self::convertToA1($cellReference[0][0], $currentRowNumber, $currentColumnNumber);
|
||||
$value = substr_replace($value, $A1CellReference, $cellReference[0][1], strlen($cellReference[0][0]));
|
||||
}
|
||||
}
|
||||
}
|
||||
unset($value);
|
||||
}
|
||||
|
||||
// Then rebuild the formula string
|
||||
$formula = implode('"', $temp);
|
||||
// Convert R1C1 style references to A1 style references (but only when not quoted)
|
||||
$temp = explode('"', $formula);
|
||||
$key = false;
|
||||
foreach ($temp as &$value) {
|
||||
// Only replace in alternate array entries (i.e. non-quoted blocks)
|
||||
if ($key = !$key) {
|
||||
preg_match_all(self::R1C1_COORDINATE_REGEX, $value, $cellReferences, PREG_SET_ORDER + PREG_OFFSET_CAPTURE);
|
||||
// Reverse the matches array, otherwise all our offsets will become incorrect if we modify our way
|
||||
// through the formula from left to right. Reversing means that we work right to left.through
|
||||
// the formula
|
||||
$cellReferences = array_reverse($cellReferences);
|
||||
// Loop through each R1C1 style reference in turn, converting it to its A1 style equivalent,
|
||||
// then modify the formula to use that new reference
|
||||
foreach ($cellReferences as $cellReference) {
|
||||
$A1CellReference = self::convertToA1($cellReference[0][0], $currentRowNumber, $currentColumnNumber);
|
||||
$value = substr_replace($value, $A1CellReference, $cellReference[0][1], strlen($cellReference[0][0]));
|
||||
}
|
||||
}
|
||||
}
|
||||
unset($value);
|
||||
|
||||
return $formula;
|
||||
// Then rebuild the formula string
|
||||
return implode('"', $temp);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -7,6 +7,29 @@ use PHPUnit\Framework\TestCase;
|
|||
|
||||
class FontTest extends TestCase
|
||||
{
|
||||
public function testSize(): void
|
||||
{
|
||||
$spreadsheet = new Spreadsheet();
|
||||
$sheet = $spreadsheet->getActiveSheet();
|
||||
$cell = $sheet->getCell('A1');
|
||||
$cell->setValue('Cell A1');
|
||||
$font = $cell->getStyle()->getFont();
|
||||
|
||||
$font->setSize(15);
|
||||
self::assertSame(15, $font->getSize(), 'Set to 15');
|
||||
|
||||
$font->setSize('');
|
||||
self::assertSame(10, $font->getSize(), 'Should be the default 10');
|
||||
|
||||
$font->setSize(14);
|
||||
$font->setSize(0);
|
||||
self::assertSame(10, $font->getSize(), 'Should be the default 10');
|
||||
|
||||
$font->setSize(13);
|
||||
$font->setSize(-1);
|
||||
self::assertSame(13, $font->getSize(), 'Should still be 13');
|
||||
}
|
||||
|
||||
public function testSuperSubScript(): void
|
||||
{
|
||||
$spreadsheet = new Spreadsheet();
|
||||
|
|
|
|||
Loading…
Reference in New Issue