private static function replaceByPosition(string $subject, string $replace, $position, string $search): string
    {
        if ($position !== false) {
            return \substr_replace($subject, $replace, $position, \mb_strlen($search));
        }

        return $subject;
    }
private static function replaceByPosition(string $subject, string $replace, $position, string $search): string
    {
        if ($position !== false) {
            return \substr_replace($subject, $replace, $position, \mb_strlen($search));
        }

        return $subject;
    }
private static function replaceByPosition ( string $ subject , string $ replace , $ position , string $ search ) : string { if ( $ position !== false ) { return \ substr_replace ( $ subject , $ replace , $ position , \ mb_strlen ( $ search ) ) ; } return $ subject ; }
Helper function for replaceLast and replaceFirst.

@param string   $subject
@param string   $replace
@param bool|int $position
@param string   $search

@return string
Helper function for replaceLast and replaceFirst .