<?php
/**
 * weLaunch Descriptor Types Class
 *
 * @class weLaunch_Descriptor_Types
 * @version 4.0.0
 * @package weLaunch Framework
 * @author Tofandel
 */

// Exit if accessed directly.
defined( 'ABSPATH' ) || exit;

/**
 * Class weLaunch_Descriptor_Types
 */
abstract class weLaunch_Descriptor_Types {
	const TEXT     = 'text';
	const TEXTAREA = 'textarea';
	const BOOL     = 'bool';
	const SLIDER   = 'slider';
	const NUMBER   = 'number';
	const RANGE    = 'range';
	const OPTIONS  = 'array';
	const WP_DATA  = 'wp_data';
	const RADIO    = 'radio';
	// Todo add more field types for the builder!

	/**
	 * Get the available types of field.
	 *
	 * @return array
	 */
	public static function get_types() {
		static $const_cache;

		if ( ! isset( $const_cache ) ) {
			$reflect     = new ReflectionClass( __CLASS__ );
			$const_cache = $reflect->getConstants();
		}

		return $const_cache;
	}


	/**
	 * Check if a type is in the list of available types.
	 *
	 * @param string $value Check if it's a valid type.
	 *
	 * @return bool
	 */
	public static function is_valid_type( $value ) {
		return in_array( $value, self::get_types(), true );
	}

}
