<?php
/**
 * ModuleType class.
 *
 * Provides static module metadata and utility conversion methods.
 *
 * @package Ilabs\Firevert\Modules\PowerWidget\Services\Type
 */

declare( strict_types=1 );

namespace Ilabs\Firevert\Modules\SpectatorViews\Services\Type;

/**
 * Class ModuleType
 *
 * Converts module slug into folder name and display title.
 */
final class ModuleType {

	/**
	 * The module slug in snake_case format.
	 *
	 * @var string
	 */
	public const MODULE_SLUG = 'spectator_views';

	/**
	 * The module post type in snake_case format.
	 *
	 * @var string
	 */
	public const MODULE_CPT = 'fv_' . self::MODULE_SLUG;
	/**
	 * Converts the module slug to CamelCase folder name.
	 *
	 * @return string The folder name in CamelCase.
	 */
	public static function get_module_folder_name_from_slug(): string {
		return implode( '', self::get_filtered_slug_parts() );
	}

	/**
	 * Converts the module slug to a human-readable module title.
	 *
	 * @return string The module title with spaces.
	 */
	public static function get_module_title_from_slug(): string {
		return implode( ' ', self::get_filtered_slug_parts() );
	}

	/**
	 * Converts the module slug into an array of capitalized words.
	 *
	 * @return string[] Array of capitalized words.
	 */
	private static function get_slug_parts(): array {
		$parts = explode( '_', self::MODULE_SLUG );
		return array_map( 'ucfirst', $parts );
	}

	/**
	 * Returns filtered slug parts (without 'firevert').
	 *
	 * @return string[] Array of capitalized words.
	 */
	private static function get_filtered_slug_parts(): array {
		return array_filter(
			self::get_slug_parts(),
			static function ( string $part ) {
				return strtolower( $part ) !== 'firevert';
			}
		);
	}
}
