Skip to content

Commit

Permalink
fix: add new endsWith() from core. bump version.
Browse files Browse the repository at this point in the history
build:  [skip-ci]
  • Loading branch information
lots0logs committed Aug 28, 2020
1 parent 50cd55f commit 820f2b7
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "Utilities that make reading and writing PHP code more convenient and enjoyable",
"type": "library",
"license": "GPL-v2-or-later",
"version": "1.1.0",
"version": "1.1.1",
"authors": [
{
"name": "Elegant Themes",
Expand Down
20 changes: 20 additions & 0 deletions src/Utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,26 @@ public function arrayUpdate( &$array, $path, $value ): void {
$this->arraySet( $array, $path, array_merge( $current_value, $value ) );
}

/**
* Whether or not a string ends with a substring.
*
* @since 1.1.1
*
* @param string $haystack The string to look in.
* @param string $needle The string to look for.
*
* @return bool
*/
public function endsWith( string $haystack, string $needle ): bool {
$length = strlen( $needle );

if ( 0 === $length ) {
return true;
}

return ( substr( $haystack, -$length ) === $needle );
}

public function ensureDirectoryExists( $path ): bool {
if ( file_exists( $path ) ) {
return is_dir( $path );
Expand Down

0 comments on commit 820f2b7

Please sign in to comment.