wpdatatables
/
lib
/
phpoffice
/
phpspreadsheet
/
src
/
PhpSpreadsheet
/
Style
/
ConditionalFormatting
/
Wizard.php
Wizard.php in wpDataTables – WordPress Data Table, Dynamic Tables & Table Charts Plugin 6.5.1.7, at lib/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard.php
| 1 | <?php |
| 2 | |
| 3 | namespace PhpOffice\PhpSpreadsheet\Style\ConditionalFormatting; |
| 4 | |
| 5 | use PhpOffice\PhpSpreadsheet\Exception; |
| 6 | use PhpOffice\PhpSpreadsheet\Style\Conditional; |
| 7 | use PhpOffice\PhpSpreadsheet\Style\ConditionalFormatting\Wizard\WizardInterface; |
| 8 | |
| 9 | class Wizard |
| 10 | { |
| 11 | public const CELL_VALUE = 'cellValue'; |
| 12 | public const TEXT_VALUE = 'textValue'; |
| 13 | public const BLANKS = Conditional::CONDITION_CONTAINSBLANKS; |
| 14 | public const NOT_BLANKS = Conditional::CONDITION_NOTCONTAINSBLANKS; |
| 15 | public const ERRORS = Conditional::CONDITION_CONTAINSERRORS; |
| 16 | public const NOT_ERRORS = Conditional::CONDITION_NOTCONTAINSERRORS; |
| 17 | public const EXPRESSION = Conditional::CONDITION_EXPRESSION; |
| 18 | public const FORMULA = Conditional::CONDITION_EXPRESSION; |
| 19 | public const DATES_OCCURRING = 'DateValue'; |
| 20 | public const DUPLICATES = Conditional::CONDITION_DUPLICATES; |
| 21 | public const UNIQUE = Conditional::CONDITION_UNIQUE; |
| 22 | |
| 23 | public const VALUE_TYPE_LITERAL = 'value'; |
| 24 | public const VALUE_TYPE_CELL = 'cell'; |
| 25 | public const VALUE_TYPE_FORMULA = 'formula'; |
| 26 | |
| 27 | /** |
| 28 | * @var string |
| 29 | */ |
| 30 | protected $cellRange; |
| 31 | |
| 32 | public function __construct(string $cellRange) |
| 33 | { |
| 34 | $this->cellRange = $cellRange; |
| 35 | } |
| 36 | |
| 37 | public function newRule(string $ruleType): WizardInterface |
| 38 | { |
| 39 | switch ($ruleType) { |
| 40 | case self::CELL_VALUE: |
| 41 | return new Wizard\CellValue($this->cellRange); |
| 42 | case self::TEXT_VALUE: |
| 43 | return new Wizard\TextValue($this->cellRange); |
| 44 | case self::BLANKS: |
| 45 | return new Wizard\Blanks($this->cellRange, true); |
| 46 | case self::NOT_BLANKS: |
| 47 | return new Wizard\Blanks($this->cellRange, false); |
| 48 | case self::ERRORS: |
| 49 | return new Wizard\Errors($this->cellRange, true); |
| 50 | case self::NOT_ERRORS: |
| 51 | return new Wizard\Errors($this->cellRange, false); |
| 52 | case self::EXPRESSION: |
| 53 | case self::FORMULA: |
| 54 | return new Wizard\Expression($this->cellRange); |
| 55 | case self::DATES_OCCURRING: |
| 56 | return new Wizard\DateValue($this->cellRange); |
| 57 | case self::DUPLICATES: |
| 58 | return new Wizard\Duplicates($this->cellRange, false); |
| 59 | case self::UNIQUE: |
| 60 | return new Wizard\Duplicates($this->cellRange, true); |
| 61 | default: |
| 62 | throw new Exception('No wizard exists for this CF rule type'); |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | public static function fromConditional(Conditional $conditional, string $cellRange = 'A1'): WizardInterface |
| 67 | { |
| 68 | $conditionalType = $conditional->getConditionType(); |
| 69 | |
| 70 | switch ($conditionalType) { |
| 71 | case Conditional::CONDITION_CELLIS: |
| 72 | return Wizard\CellValue::fromConditional($conditional, $cellRange); |
| 73 | case Conditional::CONDITION_CONTAINSTEXT: |
| 74 | case Conditional::CONDITION_NOTCONTAINSTEXT: |
| 75 | case Conditional::CONDITION_BEGINSWITH: |
| 76 | case Conditional::CONDITION_ENDSWITH: |
| 77 | return Wizard\TextValue::fromConditional($conditional, $cellRange); |
| 78 | case Conditional::CONDITION_CONTAINSBLANKS: |
| 79 | case Conditional::CONDITION_NOTCONTAINSBLANKS: |
| 80 | return Wizard\Blanks::fromConditional($conditional, $cellRange); |
| 81 | case Conditional::CONDITION_CONTAINSERRORS: |
| 82 | case Conditional::CONDITION_NOTCONTAINSERRORS: |
| 83 | return Wizard\Errors::fromConditional($conditional, $cellRange); |
| 84 | case Conditional::CONDITION_TIMEPERIOD: |
| 85 | return Wizard\DateValue::fromConditional($conditional, $cellRange); |
| 86 | case Conditional::CONDITION_EXPRESSION: |
| 87 | return Wizard\Expression::fromConditional($conditional, $cellRange); |
| 88 | case Conditional::CONDITION_DUPLICATES: |
| 89 | case Conditional::CONDITION_UNIQUE: |
| 90 | return Wizard\Duplicates::fromConditional($conditional, $cellRange); |
| 91 | default: |
| 92 | throw new Exception('No wizard exists for this CF rule type'); |
| 93 | } |
| 94 | } |
| 95 | } |
| 96 |