<?php

namespace WPEventGenius\Common\SEO\Compatibility;

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

class RankMathSEOCompatibility implements SEOCompatibilityInterface {

	/**
	 * @inheritDoc
	 */
	public function is_available() {
		return function_exists( 'rank_math_the_breadcrumbs' );
	}

	/**
	 * @inheritDoc
	 */
	public function render( $post_id, array $breadcrumb_context = array() ) {
		if ( ! $this->is_available() ) {
			return '';
		}

		ob_start();
		rank_math_the_breadcrumbs();
		$breadcrumbs = ob_get_clean();

		if ( ! is_string( $breadcrumbs ) ) {
			return '';
		}

		return trim( $breadcrumbs );
	}
}
