<?php
/**
 * Footer copyright component.
 *
 * @package Kutby
 * @since   2.7.0
 */

declare(strict_types=1);

namespace Kutby\Footer\Components;

use Kutby\Footer\Contracts\FooterComponentInterface;
use Kutby\Footer\Support\FooterContext;

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

/**
 * Class Copyright
 */
final class Copyright implements FooterComponentInterface {

	/**
	 * {@inheritdoc}
	 */
	public static function render( FooterContext $ctx, array $args = array() ): void {
		$custom = $ctx->string( 'copyright' );
		$class  = isset( $args['class'] ) ? (string) $args['class'] : 'kutby-footer-copyright';
		?>
		<div class="<?php echo esc_attr( $class ); ?>">
			<?php if ( '' !== $custom ) : ?>
				<p><?php echo wp_kses_post( $custom ); ?></p>
			<?php else : ?>
				<p>
					&copy; <?php echo esc_html( gmdate( 'Y' ) ); ?>
					<a href="<?php echo esc_url( home_url( '/' ) ); ?>"><?php bloginfo( 'name' ); ?></a>
				</p>
			<?php endif; ?>
		</div>
		<?php
	}
}
