@@ -79,13 +79,11 @@ public function toToml(): string
7979 *
8080 * @param bool $condition The condition to assert.
8181 * @param non-empty-string $message The exception message if the assertion fails.
82- * @return false Returns false if the assertion passes
8382 * @throws \InvalidArgumentException If the assertion fails.
8483 */
85- private static function notAssert (bool $ condition , string $ message ): bool
84+ private static function assert (bool $ condition , string $ message ): void
8685 {
8786 $ condition or throw new \InvalidArgumentException ($ message );
88- return false ;
8987 }
9088
9189 /**
@@ -97,18 +95,12 @@ private static function notAssert(bool $condition, string $message): bool
9795 */
9896 private static function parseProfiles (mixed $ profile ): array
9997 {
100- if (self ::notAssert (\is_array ($ profile ), 'The `profile` section must be an array. ' )) {
101- return [];
102- }
98+ self ::assert (\is_array ($ profile ), 'The `profile` section must be an array. ' );
10399
104100 $ result = [];
105101 foreach ($ profile as $ name => $ config ) {
106- if (
107- self ::notAssert (\is_array ($ config ), 'Each profile configuration must be an array. ' )
108- || self ::notAssert (\strlen ($ name ) > 0 , 'Profile name must be a non-empty string. ' )
109- ) {
110- continue ;
111- }
102+ self ::assert (\is_array ($ config ), 'Each profile configuration must be an array. ' );
103+ self ::assert (\strlen ($ name ) > 0 , 'Profile name must be a non-empty string. ' );
112104
113105 $ apiKey = $ config ['api_key ' ] ?? null ;
114106 $ tls = $ config ['tls ' ] ?? null ;
@@ -118,6 +110,7 @@ private static function parseProfiles(mixed $profile): array
118110 default => new ConfigTls (disabled: true ),
119111 };
120112
113+ /** @var non-empty-string $name */
121114 $ result [$ name ] = new ConfigProfile (
122115 address: $ config ['address ' ] ?? null ,
123116 namespace: $ config ['namespace ' ] ?? null ,
@@ -138,19 +131,19 @@ private static function parseTls(array $tls): ?ConfigTls
138131 $ privateKey = $ tls ['client_key_path ' ] ?? $ tls ['client_key_data ' ] ?? null ;
139132 $ certChain = $ tls ['client_cert_path ' ] ?? $ tls ['client_cert_data ' ] ?? null ;
140133
141- $ rootCert === null or self ::notAssert (
134+ $ rootCert === null or self ::assert (
142135 isset ($ tls ['server_ca_cert_path ' ]) xor isset ($ tls ['server_ca_cert_data ' ]),
143136 'Cannot specify both `server_ca_cert_path` and `server_ca_cert_data`. ' ,
144137 );
145- $ privateKey === null or self ::notAssert (
138+ $ privateKey === null or self ::assert (
146139 isset ($ tls ['client_key_path ' ]) xor isset ($ tls ['client_key_data ' ]),
147140 'Cannot specify both `client_key_path` and `client_key_data`. ' ,
148141 );
149- $ certChain === null or self ::notAssert (
142+ $ certChain === null or self ::assert (
150143 isset ($ tls ['client_cert_path ' ]) xor isset ($ tls ['client_cert_data ' ]),
151144 'Cannot specify both `client_cert_path` and `client_cert_data`. ' ,
152145 );
153- self ::notAssert (
146+ self ::assert (
154147 ($ privateKey === null ) === ($ certChain === null ),
155148 'Both `client_key_*` and `client_cert_*` must be specified for mTLS. ' ,
156149 );
0 commit comments