cellRange = $cellRange; } public function newRule(string $ruleType): WizardInterface { return match ($ruleType) { self::CELL_VALUE => new Wizard\CellValue($this->cellRange), self::TEXT_VALUE => new Wizard\TextValue($this->cellRange), self::BLANKS => new Wizard\Blanks($this->cellRange, true), self::NOT_BLANKS => new Wizard\Blanks($this->cellRange, false), self::ERRORS => new Wizard\Errors($this->cellRange, true), self::NOT_ERRORS => new Wizard\Errors($this->cellRange, false), self::EXPRESSION, self::FORMULA => new Wizard\Expression($this->cellRange), self::DATES_OCCURRING => new Wizard\DateValue($this->cellRange), self::DUPLICATES => new Wizard\Duplicates($this->cellRange, false), self::UNIQUE => new Wizard\Duplicates($this->cellRange, true), default => throw new Exception('No wizard exists for this CF rule type'), }; } public static function fromConditional(Conditional $conditional, string $cellRange = 'A1'): WizardInterface { $conditionalType = $conditional->getConditionType(); return match ($conditionalType) { Conditional::CONDITION_CELLIS => Wizard\CellValue::fromConditional($conditional, $cellRange), Conditional::CONDITION_CONTAINSTEXT, Conditional::CONDITION_NOTCONTAINSTEXT, Conditional::CONDITION_BEGINSWITH, Conditional::CONDITION_ENDSWITH => Wizard\TextValue::fromConditional($conditional, $cellRange), Conditional::CONDITION_CONTAINSBLANKS, Conditional::CONDITION_NOTCONTAINSBLANKS => Wizard\Blanks::fromConditional($conditional, $cellRange), Conditional::CONDITION_CONTAINSERRORS, Conditional::CONDITION_NOTCONTAINSERRORS => Wizard\Errors::fromConditional($conditional, $cellRange), Conditional::CONDITION_TIMEPERIOD => Wizard\DateValue::fromConditional($conditional, $cellRange), Conditional::CONDITION_EXPRESSION => Wizard\Expression::fromConditional($conditional, $cellRange), Conditional::CONDITION_DUPLICATES, Conditional::CONDITION_UNIQUE => Wizard\Duplicates::fromConditional($conditional, $cellRange), default => throw new Exception('No wizard exists for this CF rule type'), }; } }