<commit_before><?php
namespace JasonKaz\FormBuild;

/**
 * Creates a select input
 */
class Select extends FormInput   {
    /**
     * Initializes the select
     *
     * @param array $Options Available options for the input
     * @param null|array $Selected The default selected option. Can be a single option or an array of options. Options start with an index of 0
     * @param array $Attribs
     */
    public function __construct($Options=array(), $Selected=null, $Attribs=array()){
        $this->Code.='<select';
        $this->Code.=parent::parseAttribs($Attribs);
        $this->Code.='>';

        //Convert $Selected to array if necessary
        $Selected=(array)$Selected;

        foreach($Options as $key=>$val){
            $this->Code.='<option value="'.$key.'"';

            if (in_array($key, $Selected, true))
                $this->Code.=' selected';

            $this->Code.='>'.$val.'</option>';
        }

        $this->Code.='</select>';

        $this->Attribs=$Attribs;<commit_msg>Avoid unnecessary array conversion<commit_after><?php
namespace JasonKaz\FormBuild;

/**
 * Creates a select input
 */
class Select extends FormInput   {
    /**
     * Initializes the select
     *
     * @param array $Options Available options for the input
     * @param null|array $Selected The default selected option. Can be a single option or an array of options. Options start with an index of 0
     * @param array $Attribs
     */
    public function __construct($Options=array(), $Selected=null, $Attribs=array()){
        $this->Code.='<select';
        $this->Code.=parent::parseAttribs($Attribs);
        $this->Code.='>';

        //Convert $Selected to array if necessary
        if(!is_array($Selected))
            $Selected=(array)$Selected;

        foreach($Options as $key=>$val){
            $this->Code.='<option value="'.$key.'"';

            if (in_array($key, $Selected, true))
                $this->Code.=' selected';

            $this->Code.='>'.$val.'</option>';
        }

        $this->Code.='</select>';

        $this->Attribs=$Attribs;
{'fraction_non_alphanumeric': 0.15789473684210525, 'fraction_numerical': 0.0009569377990430622, 'mean_word_length': 2.4792013311148087, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2216293', 'n_tokens_mistral': 591, 'n_tokens_neox': 589, 'n_words': 159}