<commit_before><?php
namespace Noce;

class Form implements \ArrayAccess, \Iterator, \Countable
{
    public $_items = array();
    public $_current = 0;
    public $_disabled = false;
    
    public function __construct($value = array())
    {
        $this->init();
        $this->setValue($value);
    }
    
    /**
     * Create items and add them to the form
     *
     * called by __construct()
     */
    public function init()
    {
    }
    
    public function getValue()
    {
        if ($this->_disabled) {
            return array();
        }
        $values = array();
        foreach ($this->getEnabledItems() as $i => $item) {
            $values[$i] = $item->getValue();
        }
        return $values;
    }

    public function setValue($values)
    {
        foreach ($this->_items as $i => $item) {
            if (isset($values[$i])) {
                $item->setValue($values[$i]);
            }
        }
    }

    public function clear()
    {
        foreach ($this->_items as $i => $item) {
            $item->clear();
        }
    }

    public function isEmpty()
    {
        if ($this->_disabled) {
            return true;
        }
        foreach ($this->getEnabledItems() as $i => $item) {
            if (!$item->isEmpty()) {
                return false;
            }
        }
        return true;
    }
<commit_msg>Clear value if a multi-value input (select / checkbox) was not selected<commit_after><?php
namespace Noce;

class Form implements \ArrayAccess, \Iterator, \Countable
{
    public $_items = array();
    public $_current = 0;
    public $_disabled = false;
    
    public function __construct($value = array())
    {
        $this->init();
        $this->setValue($value);
    }
    
    /**
     * Create items and add them to the form
     *
     * called by __construct()
     */
    public function init()
    {
    }
    
    public function getValue()
    {
        if ($this->_disabled) {
            return array();
        }
        $values = array();
        foreach ($this->getEnabledItems() as $i => $item) {
            $values[$i] = $item->getValue();
        }
        return $values;
    }

    public function setValue($values)
    {
        foreach ($this->_items as $i => $item) {
            $item->setValue(@$values[$i]);
        }
    }

    public function clear()
    {
        foreach ($this->_items as $i => $item) {
            $item->clear();
        }
    }

    public function isEmpty()
    {
        if ($this->_disabled) {
            return true;
        }
        foreach ($this->getEnabledItems() as $i => $item) {
            if (!$item->isEmpty()) {
                return false;
            }
        }
        return true;
    }

{'fraction_non_alphanumeric': 0.14233443102817417, 'fraction_numerical': 0.0007317965605561653, 'mean_word_length': 1.5456238361266295, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 35, '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': '5470696', 'n_tokens_mistral': 775, 'n_tokens_neox': 770, 'n_words': 196}