Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stacked Alignment - Use Class Constant Rather than Literal #1716

Merged
merged 5 commits into from
Feb 3, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 14 additions & 12 deletions src/PhpSpreadsheet/Writer/Xls/Xf.php
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,12 @@ private static function mapTextRotation($textRotation)
return 90 - $textRotation;
}

private const LOCK_ARRAY = [
Protection::PROTECTION_INHERIT => 1,
Protection::PROTECTION_PROTECTED => 1,
Protection::PROTECTION_UNPROTECTED => 0,
];

/**
* Map locked.
*
Expand All @@ -498,14 +504,15 @@ private static function mapTextRotation($textRotation)
*/
private static function mapLocked($locked)
{
switch ($locked) {
case Protection::PROTECTION_UNPROTECTED:
return 0;
}

return 1;
return array_key_exists($locked, self::LOCK_ARRAY) ? LOCK_ARRAY[$locked] : 1;
oleibman marked this conversation as resolved.
Show resolved Hide resolved
}

private const HIDDEN_ARRAY = [
Protection::PROTECTION_INHERIT => 0,
Protection::PROTECTION_PROTECTED => 1,
Protection::PROTECTION_UNPROTECTED => 0,
];

/**
* Map hidden.
*
Expand All @@ -515,11 +522,6 @@ private static function mapLocked($locked)
*/
private static function mapHidden($hidden)
{
switch ($hidden) {
case Protection::PROTECTION_PROTECTED:
return 1;
}

return 0;
return array_key_exists($hidden, self::HIDDEN_ARRAY) ? HIDDEN_ARRAY[$hidden] : 0;
}
oleibman marked this conversation as resolved.
Show resolved Hide resolved
}