Skip to content

Commit 10d4cd5

Browse files
authored
Fix PHPStan errors (#100)
1 parent a14f218 commit 10d4cd5

1 file changed

Lines changed: 17 additions & 8 deletions

File tree

‎src/Provider_Command.php‎

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -154,15 +154,24 @@ public function match_provider( $args, $assoc_args ) {
154154
$response_size_limit = Utils\get_flag_value( $assoc_args, 'limit-response-size' );
155155
$link_type = Utils\get_flag_value( $assoc_args, 'link-type' );
156156

157-
if ( ! $discover && ( null !== $response_size_limit || null !== $link_type ) ) {
158-
if ( null !== $response_size_limit && null !== $link_type ) {
159-
$msg = "The 'limit-response-size' and 'link-type' options can only be used with discovery.";
160-
} elseif ( null !== $response_size_limit ) {
161-
$msg = "The 'limit-response-size' option can only be used with discovery.";
162-
} else {
163-
$msg = "The 'link-type' option can only be used with discovery.";
157+
if ( ! $discover ) {
158+
$discovery_options = [];
159+
if ( null !== $response_size_limit ) {
160+
$discovery_options[] = "'limit-response-size'";
161+
}
162+
if ( null !== $link_type ) {
163+
$discovery_options[] = "'link-type'";
164+
}
165+
166+
if ( ! empty( $discovery_options ) ) {
167+
WP_CLI::error(
168+
sprintf(
169+
'The %s %s can only be used with discovery.',
170+
implode( ' and ', $discovery_options ),
171+
count( $discovery_options ) > 1 ? 'options' : 'option'
172+
)
173+
);
164174
}
165-
WP_CLI::error( $msg );
166175
}
167176

168177
if ( $response_size_limit ) {

0 commit comments

Comments
 (0)