argb = $pARGB; } /** * Get ARGB. * * @return string */ public function getARGB() { return $this->argb; } /** * Set ARGB. * * @param string $pValue * * @return \PhpOffice\PhpPresentation\Style\Color */ public function setARGB($pValue = self::COLOR_BLACK) { if ('' == $pValue) { $pValue = self::COLOR_BLACK; } $this->argb = $pValue; return $this; } /** * Get the alpha % of the ARGB * Will return 100 if no ARGB. * * @return int */ public function getAlpha(): int { $alpha = 100; if (\strlen($this->argb) >= 6) { $dec = \hexdec(\substr($this->argb, 0, 2)); $alpha = (int) \number_format(($dec / 255) * 100, 0); } return $alpha; } /** * Set the alpha % of the ARGB. * * @param int $alpha * * @return $this */ public function setAlpha(int $alpha = 100): self { if ($alpha < 0) { $alpha = 0; } if ($alpha > 100) { $alpha = 100; } $alpha = \round(($alpha / 100) * 255); $alpha = \dechex((int) $alpha); $alpha = \str_pad($alpha, 2, '0', STR_PAD_LEFT); $this->argb = $alpha . \substr($this->argb, 2); return $this; } /** * Get RGB. * * @return string */ public function getRGB() { if (6 == \strlen($this->argb)) { return $this->argb; } else { return \substr($this->argb, 2); } } /** * Set RGB. * * @param string $pValue * @param string $pAlpha * * @return \PhpOffice\PhpPresentation\Style\Color */ public function setRGB($pValue = '000000', $pAlpha = 'FF') { if ('' == $pValue) { $pValue = '000000'; } if ('' == $pAlpha) { $pAlpha = 'FF'; } $this->argb = $pAlpha . $pValue; return $this; } /** * Get hash code. * * @return string Hash code */ public function getHashCode(): string { return \md5( $this->argb . __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; } }