<?php
/**
 * File Path: includes/data/class-mbs-onix-lists.php
 *
 * ONIX Reference Code Lists
 *
 * Static class exposing curated subsets of ONIX code lists used by MBS:
 *   - List 28: Audience codes (mbs_audience_code)
 *   - List 21: Edition type codes (mbs_edition_type)
 *   - List 25: Illustration type codes (mbs_illustration_types)
 *
 * Source: EDItEUR ONIX for Books 3.0 Code Lists.
 *
 * @package    My_Book_Showroom
 * @subpackage Includes/Data
 * @since      1.1.0
 */

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

class MBS_ONIX_Lists { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedClassFound -- mbs_/MBS_ prefix is correct; scanner not configured with plugin prefix

	/**
	 * ONIX List 28 — Audience code (subset used by MBS).
	 * code => label
	 *
	 * @return array<string,string>
	 */
	public static function audience_codes(): array {
		return array(
			'01' => 'General / Trade',
			'02' => 'Children / Juvenile',
			'03' => 'Young Adult',
			'04' => 'Primary and Secondary Education',
			'05' => 'College / Higher Education',
			'06' => 'Professional and Scholarly',
			'07' => 'ELT / ESL',
			'08' => 'Adult Education',
			'09' => 'Second Language Teaching',
		);
	}

	/**
	 * ONIX List 21 — Edition type code (subset used by MBS).
	 * code => label
	 *
	 * @return array<string,string>
	 */
	public static function edition_types(): array {
		return array(
			'ABR' => 'Abridged edition',
			'ADP' => 'Adapted edition',
			'ALT' => 'Alternate',
			'ANN' => 'Annotated edition',
			'BLL' => 'Bilingual edition',
			'BRL' => 'Braille edition',
			'CMB' => 'Combined volume',
			'CRI' => 'Critical edition',
			'ENL' => 'Enlarged edition',
			'EXP' => 'Expanded edition',
			'FAC' => 'Facsimile edition',
			'ILL' => 'Illustrated edition',
			'LTE' => 'Large type / large print edition',
			'NED' => 'New edition',
			'NUM' => 'Edition with numbered copies',
			'REP' => 'Reprint',
			'REV' => 'Revised edition',
			'SCH' => 'School edition',
			'UBR' => 'Unabridged edition',
			'UPD' => 'Updated edition',
			'VAR' => 'Variorum edition',
		);
	}

	/**
	 * ONIX List 25 — Illustration type (curated subset used by MBS).
	 * code => label
	 *
	 * @return array<string,string>
	 */
	public static function illustration_types(): array {
		return array(
			'01' => 'Illustrations, unspecified',
			'02' => 'Halftones, unspecified',
			'03' => 'Line drawings, unspecified',
			'04' => 'Tables, unspecified',
			'05' => 'Illustrations, black and white',
			'06' => 'Illustrations, color',
			'08' => 'Figures',
			'09' => 'Maps',
			'10' => 'Bibliographies',
			'11' => 'Indexes',
			'12' => 'Photographs',
			'14' => 'Charts',
			'15' => 'Diagrams',
			'16' => 'Plates, unspecified',
		);
	}

	/**
	 * Validate an audience code against the allowed set.
	 *
	 * @param string $code
	 * @return bool
	 */
	public static function is_valid_audience( string $code ): bool {
		return isset( self::audience_codes()[ $code ] );
	}

	/**
	 * Validate an edition type code against the allowed set.
	 *
	 * @param string $code
	 * @return bool
	 */
	public static function is_valid_edition_type( string $code ): bool {
		return isset( self::edition_types()[ $code ] );
	}

	/**
	 * Validate an illustration type code against the allowed set.
	 *
	 * @param string $code
	 * @return bool
	 */
	public static function is_valid_illustration_type( string $code ): bool {
		return isset( self::illustration_types()[ $code ] );
	}
}
