#984 fix Scrutinizer warnings
This commit is contained in:
parent
a757692992
commit
2b72c7e912
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace PhpOffice\PhpSpreadsheet\Reader\Xlsx;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Style\Color;
|
||||
use PhpOffice\PhpSpreadsheet\Style\Conditional;
|
||||
use PhpOffice\PhpSpreadsheet\Style\ConditionalFormatting\ConditionalDataBar;
|
||||
use PhpOffice\PhpSpreadsheet\Style\ConditionalFormatting\ConditionalFormattingRuleExtension;
|
||||
|
|
@ -39,16 +38,7 @@ class ConditionalStyles
|
|||
$conditionals = [];
|
||||
foreach ($xmlSheet->conditionalFormatting as $conditional) {
|
||||
foreach ($conditional->cfRule as $cfRule) {
|
||||
if (
|
||||
((string) $cfRule['type'] == Conditional::CONDITION_NONE
|
||||
|| (string) $cfRule['type'] == Conditional::CONDITION_CELLIS
|
||||
|| (string) $cfRule['type'] == Conditional::CONDITION_CONTAINSTEXT
|
||||
|| (string) $cfRule['type'] == Conditional::CONDITION_CONTAINSBLANKS
|
||||
|| (string) $cfRule['type'] == Conditional::CONDITION_NOTCONTAINSBLANKS
|
||||
|| (string) $cfRule['type'] == Conditional::CONDITION_NOTCONTAINSTEXT
|
||||
|| (string) $cfRule['type'] == Conditional::CONDITION_EXPRESSION)
|
||||
&& isset($this->dxfs[(int) ($cfRule['dxfId'])])
|
||||
) {
|
||||
if (Conditional::isValidConditionType((string) $cfRule['type']) && isset($this->dxfs[(int) ($cfRule['dxfId'])])) {
|
||||
$conditionals[(string) $conditional['sqref']][(int) ($cfRule['priority'])] = $cfRule;
|
||||
} elseif ((string) $cfRule['type'] == Conditional::CONDITION_DATABAR) {
|
||||
$conditionals[(string) $conditional['sqref']][(int) ($cfRule['priority'])] = $cfRule;
|
||||
|
|
|
|||
|
|
@ -17,6 +17,17 @@ class Conditional implements IComparable
|
|||
const CONDITION_DATABAR = 'dataBar';
|
||||
const CONDITION_NOTCONTAINSTEXT = 'notContainsText';
|
||||
|
||||
private const CONDITION_TYPES = [
|
||||
self::CONDITION_CELLIS,
|
||||
self::CONDITION_CONTAINSBLANKS,
|
||||
self::CONDITION_CONTAINSTEXT,
|
||||
self::CONDITION_DATABAR,
|
||||
self::CONDITION_EXPRESSION,
|
||||
self::CONDITION_NONE,
|
||||
self::CONDITION_NOTCONTAINSBLANKS,
|
||||
self::CONDITION_NOTCONTAINSTEXT,
|
||||
];
|
||||
|
||||
// Operator types
|
||||
const OPERATOR_NONE = '';
|
||||
const OPERATOR_BEGINSWITH = 'beginsWith';
|
||||
|
|
@ -301,4 +312,16 @@ class Conditional implements IComparable
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify if param is valid condition type
|
||||
*
|
||||
* @param string $type
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function isValidConditionType(string $type): bool
|
||||
{
|
||||
return in_array($type, self::CONDITION_TYPES);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue