Skip to content

Commit

Permalink
add new method
Browse files Browse the repository at this point in the history
  • Loading branch information
Leonid74 committed Mar 5, 2022
1 parent b660e39 commit d470242
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/StringHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,22 @@ public static function mb_substr( string $string, int $start, int $length = null
: \substr( $string, $start, $length );
}

// @codingStandardsIgnoreLine
public static function mb_substr_replace( string $string, string $replacement, int $start, int $length = null ): string
{
if ( \is_null( $length ) ) {
return static::mb_substr( $string, 0, $start ) . $replacement;
}

if ( $length < 0 ) {
$length = static::mb_strlen( $string ) - $start + $length;
}

return static::mb_substr( $string, 0, $start ) .
$replacement .
static::mb_substr( $string, $start + $length, static::mb_strlen( $string ) );
}

// @codingStandardsIgnoreLine
public static function mb_strlen( ?string $string = '' ): int
{
Expand Down Expand Up @@ -340,6 +356,7 @@ public static function generateUniqId( int $length = 5, string $prefix = '' ): s
*
* @return string
*/
// @codingStandardsIgnoreLine
public static function hidingData( $data = null, array $aDataToHide = [] ): string
{
if ( empty( $data ) || ( empty( static::$aDataToHide ) && empty( $aDataToHide ) ) ) {
Expand Down

0 comments on commit d470242

Please sign in to comment.