value; } public function getType(): ValueType { return $this->type; } public function setType(ValueType $type): void { $this->type = $type; } public function getFlags(): int { return $this->flags; } public function isFlagged(int $mask): bool { return (($mask & $this->flags) === $mask); } public function isSensitive(): bool { return $this->isFlagged(IUserConfig::FLAG_SENSITIVE); } public function isIndexed(): bool { return $this->isFlagged(IUserConfig::FLAG_INDEXED); } /** * will change referenced $value with the decrypted value in case of encrypted (sensitive value) * * @param array{type: ValueType, flags: int, value: string} $valueDetail */ public function getDecryptedSensitiveValue(): string { if (!$this->isFlagged(IUserConfig::FLAG_SENSITIVE)) { return $this->value; } if ($this->decryptedValue !== null) { return $this->decryptedValue; } if (!str_starts_with($this->value, self::ENCRYPTION_PREFIX)) { return $this->value; } $this->decryptedValue = $this->crypto->decrypt(substr($this->value, self::ENCRYPTION_PREFIX_LENGTH)); return $this->decryptedValue; } public function setSensitive(bool $sensitive): void { if ($sensitive) { $this->flags |= IUserConfig::FLAG_SENSITIVE; $this->decryptedValue = $this->value; $this->value = self::ENCRYPTION_PREFIX . $this->crypto->encrypt($this->value); } else { $clearValue = $this->getDecryptedSensitiveValue(); $this->flags &= ~IUserConfig::FLAG_SENSITIVE; $this->value = $clearValue; $this->decryptedValue = null; } } public function setIndexed(bool $indexed): void { if ($indexed) { $this->flags |= IUserConfig::FLAG_INDEXED; $this->decryptedValue = $this->value; $this->value = self::ENCRYPTION_PREFIX . $this->crypto->encrypt($this->value); } else { $clearValue = $this->getDecryptedSensitiveValue(); $this->flags &= ~IUserConfig::FLAG_INDEXED; $this->value = $clearValue; $this->decryptedValue = null; } } }