Minor refactoring
This commit is contained in:
parent
586b36b440
commit
6cbb622a9e
|
@ -64,9 +64,7 @@ class PageSettings
|
|||
$pageSetupAttributes = $pageSetupValue->attributes($namespaces['x']);
|
||||
switch ($pageSetupKey) {
|
||||
case 'Layout':
|
||||
$printDefaults->orientation = (string) strtolower($pageSetupAttributes->Orientation) ?: PageSetup::ORIENTATION_PORTRAIT;
|
||||
$printDefaults->horizontalCentered = (bool) $pageSetupAttributes->CenterHorizontal ?: false;
|
||||
$printDefaults->verticalCentered = (bool) $pageSetupAttributes->CenterVertical ?: false;
|
||||
$this->setLayout($printDefaults, $pageSetupAttributes);
|
||||
|
||||
break;
|
||||
case 'Header':
|
||||
|
@ -78,10 +76,7 @@ class PageSettings
|
|||
|
||||
break;
|
||||
case 'PageMargins':
|
||||
$printDefaults->leftMargin = (float) $pageSetupAttributes->Left ?: 1.0;
|
||||
$printDefaults->rightMargin = (float) $pageSetupAttributes->Right ?: 1.0;
|
||||
$printDefaults->topMargin = (float) $pageSetupAttributes->Top ?: 1.0;
|
||||
$printDefaults->bottomMargin = (float) $pageSetupAttributes->Bottom ?: 1.0;
|
||||
$this->setMargins($printDefaults, $pageSetupAttributes);
|
||||
|
||||
break;
|
||||
}
|
||||
|
@ -117,4 +112,19 @@ class PageSettings
|
|||
|
||||
return $printDefaults;
|
||||
}
|
||||
|
||||
private function setLayout(stdClass $printDefaults, SimpleXMLElement $pageSetupAttributes): void
|
||||
{
|
||||
$printDefaults->orientation = (string)strtolower($pageSetupAttributes->Orientation) ?: PageSetup::ORIENTATION_PORTRAIT;
|
||||
$printDefaults->horizontalCentered = (bool)$pageSetupAttributes->CenterHorizontal ?: false;
|
||||
$printDefaults->verticalCentered = (bool)$pageSetupAttributes->CenterVertical ?: false;
|
||||
}
|
||||
|
||||
private function setMargins(stdClass $printDefaults, SimpleXMLElement $pageSetupAttributes): void
|
||||
{
|
||||
$printDefaults->leftMargin = (float)$pageSetupAttributes->Left ?: 1.0;
|
||||
$printDefaults->rightMargin = (float)$pageSetupAttributes->Right ?: 1.0;
|
||||
$printDefaults->topMargin = (float)$pageSetupAttributes->Top ?: 1.0;
|
||||
$printDefaults->bottomMargin = (float)$pageSetupAttributes->Bottom ?: 1.0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ class PageSetupTest extends TestCase
|
|||
{
|
||||
private const MARGIN_PRECISION = 0.00000001;
|
||||
|
||||
private const MARGIN_UNIT_CONVERSION = 2.54; // Inches to cm
|
||||
private const MARGIN_UNIT_CONVERSION = 2.54; // Inches to cm
|
||||
|
||||
/**
|
||||
* @var Spreadsheet
|
||||
|
|
|
@ -11,7 +11,7 @@ class PageSetupTest extends TestCase
|
|||
{
|
||||
private const MARGIN_PRECISION = 0.00000001;
|
||||
|
||||
private const MARGIN_UNIT_CONVERSION = 2.54; // Inches to cm
|
||||
private const MARGIN_UNIT_CONVERSION = 2.54; // Inches to cm
|
||||
|
||||
/**
|
||||
* @var Spreadsheet
|
||||
|
|
|
@ -11,7 +11,7 @@ class PageSetupTest extends TestCase
|
|||
{
|
||||
private const MARGIN_PRECISION = 0.00000001;
|
||||
|
||||
private const MARGIN_UNIT_CONVERSION = 2.54; // Inches to cm
|
||||
private const MARGIN_UNIT_CONVERSION = 2.54; // Inches to cm
|
||||
|
||||
/**
|
||||
* @var Spreadsheet
|
||||
|
|
|
@ -11,7 +11,7 @@ class PageSetupTest extends TestCase
|
|||
{
|
||||
private const MARGIN_PRECISION = 0.000001;
|
||||
|
||||
private const MARGIN_UNIT_CONVERSION = 2.54; // Inches to cm
|
||||
private const MARGIN_UNIT_CONVERSION = 2.54; // Inches to cm
|
||||
|
||||
/**
|
||||
* @var Spreadsheet
|
||||
|
|
Loading…
Reference in New Issue