Skip to content

Commit

Permalink
Remove unused method Strings::maybe_split_parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
mundschenk-at committed May 18, 2024
1 parent fe5b6cd commit 479fac9
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 46 deletions.
17 changes: 1 addition & 16 deletions src/class-strings.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
*
* @since 4.2.0
* @since 7.0.0 The deprecated static methods `mb_str_split`, and `uchr` have been removed.
* The now unused static method `maybe_split_parameters` has also been removed.
*
* @phpstan-type String_Functions array{
* 'strlen' : callable,
Expand Down Expand Up @@ -114,20 +115,4 @@ public static function functions( $str ) {

throw new Invalid_Encoding_Exception( "String '$str' uses neither ASCII nor UTF-8 encoding." );
}

/**
* If necessary, split the passed parameters string into an array.
*
* @param string[]|string $params Parameters.
*
* @return string[]
*/
public static function maybe_split_parameters( $params ) {
if ( ! \is_array( $params ) ) {
// We can safely assume an array here, as long as $params convertible to a string.
$params = \preg_split( self::RE_PARAMETER_SPLITTING, $params, -1, PREG_SPLIT_NO_EMPTY ) ?: []; // phpcs:ignore Universal.Operators.DisallowShortTernary -- Ensure array type in case of error.
}

return $params;
}
}
30 changes: 0 additions & 30 deletions tests/class-strings-test.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,34 +85,4 @@ public function test_functions_invalid_encoding() {

$this->assertEmpty( Strings::functions( \mb_convert_encoding( 'Ungültiges Encoding', 'ISO-8859-2' ) ) );
}

/**
* Provide data for testing maybe_split_parameters.
*
* @return array
*/
public function provide_maybe_split_parameters_data() {
return [
[ [], [] ],
[ '', [] ],
[ ',', [] ],
[ 'a,b', [ 'a', 'b' ] ],
[ 'foo, bar, xxx', [ 'foo', 'bar', 'xxx' ] ],
[ [ 'foo', 'bar', 'xxx' ], [ 'foo', 'bar', 'xxx' ] ],
[ [ 1, 2, 'drei' ], [ 1, 2, 'drei' ] ],
];
}

/**
* Test maybe_split_parameters.
*
* @covers ::maybe_split_parameters
* @dataProvider provide_maybe_split_parameters_data
*
* @param string|array $input Parameters sring/array.
* @param array $result Expected output.
*/
public function test_maybe_split_parameters( $input, $result ) {
$this->assertSame( $result, Strings::maybe_split_parameters( $input ) );
}
}

0 comments on commit 479fac9

Please sign in to comment.