<?php

namespace MDCE;

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

class PostTypes {

	private Settings $settings;

	public function __construct( Settings $settings ) {
		$this->settings = $settings;
	}

	public function get_supported(): array {
		$types = $this->settings->get( 'post_types' ) ?? [ 'post', 'page' ];
		return (array) apply_filters( 'mdce_supported_post_types', $types );
	}

	public function get_available(): array {
		$types = get_post_types( [ 'public' => true ], 'objects' );
		return (array) apply_filters( 'mdce_available_post_types', $types );
	}

	public function is_supported( string $post_type ): bool {
		return in_array( $post_type, $this->get_supported(), true );
	}
}
