hash = sha1($key); // Mask the key in a way that only the first 4 and last 4 characters are visible $this->mask = substr($key, 0, 4) . str_repeat('*', 24) . substr($key, -4); $this->key = $key; } #[Override] public function jsonSerialize(): ?string { return $this->key ?: $this->mask; } }