private static function calc_adjacent_length( $current_length, $adjacent_character, $haystack, array $needles, callable $substr, callable $strlen, $reverse = false ) {
		if ( $current_length > 0 && $adjacent_character !== $substr( $haystack, $reverse ? -$current_length : 0, $current_length ) ) {
			foreach ( $needles as $needle ) {
				$len = $strlen( $needle );

				if ( $needle === $substr( $haystack, ( $reverse ? -$len : 0 ), $len ) ) {
					return $len;
				}
			}
		}

		return $current_length;
	}
private static function calc_adjacent_length( $current_length, $adjacent_character, $haystack, array $needles, callable $substr, callable $strlen, $reverse = false ) {
		if ( $current_length > 0 && $adjacent_character !== $substr( $haystack, $reverse ? -$current_length : 0, $current_length ) ) {
			foreach ( $needles as $needle ) {
				$len = $strlen( $needle );

				if ( $needle === $substr( $haystack, ( $reverse ? -$len : 0 ), $len ) ) {
					return $len;
				}
			}
		}

		return $current_length;
	}
private static function calc_adjacent_length ( $ current_length , $ adjacent_character , $ haystack , array $ needles , callable $ substr , callable $ strlen , $ reverse = false ) { if ( $ current_length > 0 && $ adjacent_character !== $ substr ( $ haystack , $ reverse ? - $ current_length : 0 , $ current_length ) ) { foreach ( $ needles as $ needle ) { $ len = $ strlen ( $ needle ) ; if ( $ needle === $ substr ( $ haystack , ( $ reverse ? - $ len : 0 ) , $ len ) ) { return $ len ; } } } return $ current_length ; }
Calculates the adjacent character length.

@param  int      $current_length     The current length of the adjacent character(s).
@param  string   $adjacent_character The adjacent character.
@param  string   $haystack           The complete string.
@param  string[] $needles            The replacement(s) to look for.
@param  callable $substr             A `substr`-like function.
@param  callable $strlen             A 'strlen'-like function.
@param  bool     $reverse            Optional. Default false.

@return int
Calculates the adjacent character length .