<?php
    /**
     *  A utility class
     * 
     * @package Blog Bee
     * @since 1.0.0
     */
    use BBE\Customizer\Theme_Defaults as Theme_Defaults;
    use BBE\Customizer\Section\Section as Section;

    if( ! class_exists( 'Utility' ) ) {
        /**
         * The utility class
         */
        class Utility {

            /**
             * Convert integer number to letter number
             * 
             * @since 1.0.0
             * @param   int     $number     The number to convert
             */
            public static function convert_int_to_word( $number ): string {
                switch( $number ) {
                    case 0:
                            return 'zero';
                        break;
                    case 2:
                            return 'two';
                        break;
                    case 3:
                            return 'three';
                        break;
                    case 4:
                            return 'four';
                        break;
                    case 5:
                            return 'five';
                        break;
                    case 6:
                            return 'six';
                        break;
                    case 7:
                            return 'seven';
                        break;
                    case 8:
                            return 'eight';
                        break;
                    case 9:
                            return 'nine';
                        break;
                    default:
                        return 'one';
                        break;
                }
            }

            /**
             * Get all controls by type
             * 
             * @since 1.0.0
             */
            public static function get_controls_by_type () {
                $sections = Section::get_all_registered_sections();
                $control_by_types = [];
                foreach( $sections as $section ) {
                    $instance = $section::get_instance();
                    $controls = $instance->get_controls();
                    foreach( $controls as $control_id => $control_args ) {
                        if( ! isset( $control_args[ 'type' ] ) ) continue;
                        $type = $control_args[ 'type' ];
                        $control_by_types[ $type ][] = $control_id;
                    }
                }
                return $control_by_types;
            }
        }
    }