color = new Color(Color::COLOR_BLACK); } /** * Get Name * * @return string */ public function getName(): string { return $this->name; } /** * Set Name * * @param string $pValue * * @return self */ public function setName(string $pValue = 'Calibri'): self { if ('' == $pValue) { $pValue = 'Calibri'; } $this->name = $pValue; return $this; } /** * Get Character Spacing. * * @return float */ public function getCharacterSpacing(): float { return $this->characterSpacing; } /** * Set Character Spacing * Value in pt. * * @param float $pValue * * @return self */ public function setCharacterSpacing(float $pValue = 0): self { $this->characterSpacing = $pValue * 100; return $this; } /** * Get Size. */ public function getSize(): int { return $this->size; } /** * Set Size. */ public function setSize(int $pValue = 10): self { $this->size = $pValue; return $this; } /** * Get Bold. * * @return bool */ public function isBold(): bool { return $this->bold; } /** * Set Bold. */ public function setBold(bool $pValue = false): self { $this->bold = $pValue; return $this; } /** * Get Italic. * * @return bool */ public function isItalic(): bool { return $this->italic; } /** * Set Italic. */ public function setItalic(bool $pValue = false): self { $this->italic = $pValue; return $this; } /** * Get SuperScript. * * @return bool */ public function isSuperScript(): bool { return $this->superScript; } /** * Set SuperScript. */ public function setSuperScript(bool $pValue = false): self { $this->superScript = $pValue; // Set SubScript at false only if SuperScript is true if (true === $pValue) { $this->subScript = false; } return $this; } public function isSubScript(): bool { return $this->subScript; } public function setSubScript(bool $pValue = false): self { $this->subScript = $pValue; // Set SuperScript at false only if SubScript is true if (true === $pValue) { $this->superScript = false; } return $this; } /** * Get Underline. * * @return string */ public function getUnderline(): string { return $this->underline; } /** * Set Underline. * * @param string $pValue Underline type * * @return self */ public function setUnderline(string $pValue = self::UNDERLINE_NONE): self { if ('' == $pValue) { $pValue = self::UNDERLINE_NONE; } $this->underline = $pValue; return $this; } /** * Get Strikethrough. * * @return bool */ public function isStrikethrough(): bool { return $this->strikethrough; } /** * Set Strikethrough. */ public function setStrikethrough(bool $pValue = false): self { $this->strikethrough = $pValue; return $this; } /** * Get Color. */ public function getColor(): Color { return $this->color; } /** * Set Color. */ public function setColor(Color $pValue): self { $this->color = $pValue; return $this; } /** * Get format * * @return string */ public function getFormat(): string { return $this->format; } /** * Set format * * @param string $value * * @return self */ public function setFormat(string $value = self::FORMAT_LATIN): self { if (\in_array($value, [ self::FORMAT_COMPLEX_SCRIPT, self::FORMAT_EAST_ASIAN, self::FORMAT_LATIN, ])) { $this->format = $value; } return $this; } /** * Get hash code. * * @return string Hash code */ public function getHashCode(): string { return \md5( $this->name . $this->size . ($this->bold ? 't' : 'f') . ($this->italic ? 't' : 'f') . ($this->superScript ? 't' : 'f') . ($this->subScript ? 't' : 'f') . $this->underline . ($this->strikethrough ? 't' : 'f') . $this->format . $this->color->getHashCode() . __CLASS__ ); } /** * Get hash index. * * Note that this index may vary during script execution! Only reliable moment is * while doing a write of a workbook and when changes are not allowed. * * @return int|null Hash index */ public function getHashIndex(): ?int { return $this->hashIndex; } /** * Set hash index. * * Note that this index may vary during script execution! Only reliable moment is * while doing a write of a workbook and when changes are not allowed. * * @param int $value Hash index * * @return $this */ public function setHashIndex(int $value) { $this->hashIndex = $value; return $this; } }