$urls */ public function __construct( public readonly string|array $urls, public readonly ?string $username = null, public readonly ?string $credential = null, public readonly ?string $credentialType = null, ) {} public static function fromArray(array $data): self { $rawUrls = $data['urls'] ?? $data['url'] ?? ''; return new self( urls: is_array($rawUrls) ? array_values($rawUrls) : (string) $rawUrls, username: isset($data['username']) ? (string) $data['username'] : null, credential: isset($data['credential']) ? (string) $data['credential'] : (isset($data['password']) ? (string) $data['password'] : null), credentialType: isset($data['credentialType']) ? (string) $data['credentialType'] : null, ); } public function toArray(): array { return array_filter([ 'urls' => $this->urls, 'username' => $this->username, 'credential' => $this->credential, 'credentialType' => $this->credentialType, ], fn ($value) => $value !== null); } public function jsonSerialize(): array { return $this->toArray(); } }