PluginProbe
TablePress – Tables in WordPress made easy / 3.4
TablePress – Tables in WordPress made easy v3.4
3.4 3.3.4 3.3.3 3.3.2 3.3.1 trunk 1.12 1.14 1.9.2 2.0.4 2.1.7 2.1.8 2.2 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.3 2.3.1 2.3.2 2.4 2.4.1 2.4.2 2.4.3 All 45 releases
tablepress / libraries / vendor / PhpSpreadsheet / Style / ConditionalFormatting / Wizard.php

Wizard.php in TablePress – Tables in WordPress made easy 3.4, at libraries/vendor/PhpSpreadsheet/Style/ConditionalFormatting/Wizard.php

93 lines 3.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace TablePress\PhpOffice\PhpSpreadsheet\Style\ConditionalFormatting;
4
5 use TablePress\PhpOffice\PhpSpreadsheet\Exception;
6 use TablePress\PhpOffice\PhpSpreadsheet\Style\Conditional;
7 use TablePress\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 protected string $cellRange;
28
29 public function __construct(string $cellRange)
30 {
31 $this->cellRange = $cellRange;
32 }
33
34 public function newRule(string $ruleType): WizardInterface
35 {
36 switch ($ruleType) {
37 case self::CELL_VALUE:
38 return new Wizard\CellValue($this->cellRange);
39 case self::TEXT_VALUE:
40 return new Wizard\TextValue($this->cellRange);
41 case self::BLANKS:
42 return new Wizard\Blanks($this->cellRange, true);
43 case self::NOT_BLANKS:
44 return new Wizard\Blanks($this->cellRange, false);
45 case self::ERRORS:
46 return new Wizard\Errors($this->cellRange, true);
47 case self::NOT_ERRORS:
48 return new Wizard\Errors($this->cellRange, false);
49 case self::EXPRESSION:
50 case self::FORMULA:
51 return new Wizard\Expression($this->cellRange);
52 case self::DATES_OCCURRING:
53 return new Wizard\DateValue($this->cellRange);
54 case self::DUPLICATES:
55 return new Wizard\Duplicates($this->cellRange, false);
56 case self::UNIQUE:
57 return new Wizard\Duplicates($this->cellRange, true);
58 default:
59 throw new Exception('No wizard exists for this CF rule type');
60 }
61 }
62
63 public static function fromConditional(Conditional $conditional, string $cellRange = 'A1'): WizardInterface
64 {
65 $conditionalType = $conditional->getConditionType();
66
67 switch ($conditionalType) {
68 case Conditional::CONDITION_CELLIS:
69 return Wizard\CellValue::fromConditional($conditional, $cellRange);
70 case Conditional::CONDITION_CONTAINSTEXT:
71 case Conditional::CONDITION_NOTCONTAINSTEXT:
72 case Conditional::CONDITION_BEGINSWITH:
73 case Conditional::CONDITION_ENDSWITH:
74 return Wizard\TextValue::fromConditional($conditional, $cellRange);
75 case Conditional::CONDITION_CONTAINSBLANKS:
76 case Conditional::CONDITION_NOTCONTAINSBLANKS:
77 return Wizard\Blanks::fromConditional($conditional, $cellRange);
78 case Conditional::CONDITION_CONTAINSERRORS:
79 case Conditional::CONDITION_NOTCONTAINSERRORS:
80 return Wizard\Errors::fromConditional($conditional, $cellRange);
81 case Conditional::CONDITION_TIMEPERIOD:
82 return Wizard\DateValue::fromConditional($conditional, $cellRange);
83 case Conditional::CONDITION_EXPRESSION:
84 return Wizard\Expression::fromConditional($conditional, $cellRange);
85 case Conditional::CONDITION_DUPLICATES:
86 case Conditional::CONDITION_UNIQUE:
87 return Wizard\Duplicates::fromConditional($conditional, $cellRange);
88 default:
89 throw new Exception('No wizard exists for this CF rule type');
90 }
91 }
92 }
93