Secret
An opaque wrapper around a raw secret (a database/redis password, an API key, …) plus its non-secret {@see self::$name}. Mirrors the family secret-bearing idiom (see Milpa\Auth\Credential): the value is a `private readonly` property marked `#[\SensitiveParameter]` (redacted from stack-trace argument dumps), {@see self::__debugInfo()} redacts it, and {@see self::__serialize()} and {@see self::__clone()} refuse outright. There is deliberately NO `__toString()`. The one deliberate exit is {@see self::value()}, called only at an audited plaintext boundary. Secret-bearing objects redact the common logging paths. `var_export`/`(array)` remain able to reach the private value — they are prohibited introspection/persistence antipatterns, not defended here. `$name` is a stable, non-secret identifier (e.g. 'MYSQL_PASSWORD'). It MUST NEVER contain the value, a fragment of it, a private host, or any sensitive material.
Secret::__construct()
public function __construct(string $name, string $value):Parameters
| Name | Type | Description |
|---|---|---|
| $name | string | |
| $value | string |
Secret::required()
public static function required(string $name, ?string $raw): selfA required secret. Absence — null OR blank-after-trim — fails closed. The stored value is NEVER trimmed; `trim()` is used only to detect absence, so a password with intentional leading/trailing spaces survives verbatim.
Parameters
| Name | Type | Description |
|---|---|---|
| $name | string | |
| $raw | ?string |
Secret::optional()
public static function optional(string $name, ?string $raw): ?selfAn optional secret (e.g. a Redis password on an unauthenticated instance). Absent → null.
Parameters
| Name | Type | Description |
|---|---|---|
| $name | string | |
| $raw | ?string |
Secret::value()
public function value(): stringSecret::name()
public function name(): stringSecret::__debugInfo()
public function __debugInfo(): arraySecret::__serialize()
public function __serialize(): arrayThrows
\LogicException always
Secret::__clone()
public function __clone(): void