style = new Style(false, true); } public function getPriority(): int { return $this->priority; } public function setPriority(int $priority): self { $this->priority = $priority; return $this; } public function getNoFormatSet(): bool { return $this->noFormatSet; } public function setNoFormatSet(bool $noFormatSet): self { $this->noFormatSet = $noFormatSet; return $this; } /** * Get Condition type. */ public function getConditionType(): string { return $this->conditionType; } /** * Set Condition type. * * @param string $type Condition type, see self::CONDITION_* * * @return $this */ public function setConditionType(string $type): static { $this->conditionType = $type; return $this; } /** * Get Operator type. */ public function getOperatorType(): string { return $this->operatorType; } /** * Set Operator type. * * @param string $type Conditional operator type, see self::OPERATOR_* * * @return $this */ public function setOperatorType(string $type): static { $this->operatorType = $type; return $this; } /** * Get text. */ public function getText(): string { return $this->text; } /** * Set text. * * @return $this */ public function setText(string $text): static { $this->text = $text; return $this; } /** * Get StopIfTrue. */ public function getStopIfTrue(): bool { return $this->stopIfTrue; } /** * Set StopIfTrue. * * @return $this */ public function setStopIfTrue(bool $stopIfTrue): static { $this->stopIfTrue = $stopIfTrue; return $this; } /** * Get Conditions. * * @return (bool|float|int|string)[] */ public function getConditions(): array { return $this->condition; } /** * Set Conditions. * * @param bool|(bool|float|int|string)[]|float|int|string $conditions Condition * * @return $this */ public function setConditions($conditions): static { if (!is_array($conditions)) { $conditions = [$conditions]; } $this->condition = $conditions; return $this; } /** * Add Condition. * * @param bool|float|int|string $condition Condition * * @return $this */ public function addCondition($condition): static { $this->condition[] = $condition; return $this; } /** * Get Style. */ public function getStyle(mixed $cellData = null): Style { if ($this->conditionType === self::CONDITION_COLORSCALE && $cellData !== null && $this->colorScale !== null && is_numeric($cellData)) { $style = new Style(); $style->getFill()->setFillType(Fill::FILL_SOLID); $style->getFill()->getStartColor()->setARGB($this->colorScale->getColorForValue((float) $cellData)); return $style; } return $this->style; } /** * Set Style. * * @return $this */ public function setStyle(Style $style): static { $this->style = $style; return $this; } public function getDataBar(): ?ConditionalDataBar { return $this->dataBar; } public function setDataBar(ConditionalDataBar $dataBar): static { $this->dataBar = $dataBar; return $this; } public function getColorScale(): ?ConditionalColorScale { return $this->colorScale; } public function setColorScale(ConditionalColorScale $colorScale): static { $this->colorScale = $colorScale; return $this; } /** * Get hash code. * * @return string Hash code */ public function getHashCode(): string { return md5( $this->conditionType . $this->operatorType . implode(';', $this->condition) . $this->style->getHashCode() . __CLASS__ ); } /** * Implement PHP __clone to create a deep clone, not just a shallow copy. */ public function __clone() { $vars = get_object_vars($this); foreach ($vars as $key => $value) { if (is_object($value)) { $this->$key = clone $value; } else { $this->$key = $value; } } } /** * Verify if param is valid condition type. */ public static function isValidConditionType(string $type): bool { return in_array($type, self::CONDITION_TYPES); } }