<?php
/**
 * Polyfill cho host PHP 7.4–8.0 (plugin khai báo Requires PHP 8.1).
 *
 * @package DatvetaucaotocBooking
 */

declare(strict_types=1);

if ( ! function_exists( 'str_contains' ) ) {
	/**
	 * @param string $haystack Haystack.
	 * @param string $needle Needle.
	 */
	function str_contains( string $haystack, string $needle ): bool {
		return '' === $needle || false !== strpos( $haystack, $needle );
	}
}

if ( ! function_exists( 'str_ends_with' ) ) {
	/**
	 * @param string $haystack Haystack.
	 * @param string $needle Needle.
	 */
	function str_ends_with( string $haystack, string $needle ): bool {
		if ( '' === $needle ) {
			return true;
		}
		$len = strlen( $needle );
		if ( $len > strlen( $haystack ) ) {
			return false;
		}
		return 0 === substr_compare( $haystack, $needle, -$len );
	}
}
