<commit_before><?php
/**
 * Vision PHP-Framework
 *
 * @author <NAME> <<EMAIL>>
 * @copyright 2012-2013 <NAME>
 * @license http://www.opensource.org/licenses/mit-license.php MIT
 */ 
namespace Vision\Form;

use Vision\Html\Element as HtmlElement;

/**
 * AbstractCompositeType
 *
 * @author <NAME> <<EMAIL>>
 */ 
abstract class AbstractCompositeType extends HtmlElement
{
    protected $name = null;
    
    protected $elements = array();    
    
    protected $decorators = array();
    
    final public function __construct($name) 
    {
        $this->name = trim($name);
        $this->init();
    }     
    
    abstract public function init();
    
    public function getContent() 
    {
        $content = '';
        
        foreach ($this->elements as $element) {
            $content .= (string) $element;
        }
        
        foreach ($this->decorators as $decorator) {
            $decorator->setElement($this);
            $content = $decorator->render($content);
        }      
        
        return $content;
    }
    
    public function addElement($element) 
    {
        $this->elements[] = $element;
        return $this;
    }
    
    public function addElements(array $elements) 
    {
		foreach ($elements as $element) {
			$this->addElement($element);
		}
        return $this;
	}
    
    public function getElement($name) 
    {
        if (isset($this->elements[$name])) {
            return $this->elements[$name];
        }
		return null;
	}
    
    public function getElements()
    {
        return $this->elements;
    }
    
    public function getName()
    {
        return $this->name;
    }   

    /**
     * Add a decorator
     */
	public function addDecorator(Decorator\DecoratorInterface $decorator) 
    {
        $this->decorators[] = $decorator;
        return $this;
	}
    
    /**
     * Add decorators
     */
	public function addDecorators(array $decorators) 
    {
        foreach ($decorators as $decorator) {
            $this->addDecorator($decorator);
        }
        return $this;
	}
	
    /**
     * Get all decorators
     */
	public function getDecorators() 
    {
		return $this->decorators;
	}
    
    /**
     * Reset decorators
     */
    public function resetDecorators()
    {
        $this->decorators = array();
        return $this;
    }
}<commit_msg>dot operator already converts to string<commit_after><?php
/**
 * Vision PHP-Framework
 *
 * @author <NAME> <<EMAIL>>
 * @copyright 2012-2013 <NAME>
 * @license http://www.opensource.org/licenses/mit-license.php MIT
 */ 
namespace Vision\Form;

use Vision\Html\Element as HtmlElement;

/**
 * AbstractCompositeType
 *
 * @author <NAME> <<EMAIL>>
 */ 
abstract class AbstractCompositeType extends HtmlElement
{
    /** @type null|string $name */
    protected $name = null;
    
    /** @type array $elements */
    protected $elements = array();    
    
    /** @type array $decorators */
    protected $decorators = array();
    
    /**
     * Constructor
     * 
     * @param string $name 
     * 
     * @return void
     */
    final public function __construct($name) 
    {
        $this->name = trim($name);
        $this->init();
    }     
    
    /**
     * @return void
     */
    abstract public function init();
    
    /**
     * @return string
     */
    public function getContent() 
    {
        $content = '';
        
        foreach ($this->elements as $element) {
            $content .= $element;
        }
        
        foreach ($this->decorators as $decorator) {
            $decorator->setElement($this);
            $content = $decorator->render($content);
        }      
        
        return $content;
    }
    
    /**
     * @param <type> $element 
     * 
     * @return \Vision\Form\AbstractCompositeType Provides a fluent interface.
     */
    public function addElement($element) 
    {
        $this->elements[] = $element;
        return $this;
    }
    
    /**
     * @param array $elements 
     * 
     * @return \Vision\Form\AbstractCompositeType Provides a fluent interface.
     */
    public function addElements(array $elements) 
    {
        foreach ($elements as $element) {
            $this->addElement($element);
        }
        return $this;
    }
    
    /**
     * @param string $name 
     * 
     * @return null|mixed
     */
    public function getElement($name) 
    {
        if (isset($this->elements[$name])) {
            return $this->elements[$name];
        }
        return null;
    }
    
    /**
     * @return array
     */
    public function getElements()
    {
        return $this->elements;
    }
    
    /**
     * @return string
     */
    public function getName()
    {
        return $this->name;
    }   

    /**
     * @return \Vision\Form\AbstractCompositeType Provides a fluent interface.
     */
    public function addDecorator(Decorator\DecoratorInterface $decorator) 
    {
        $this->decorators[] = $decorator;
        return $this;
    }
    
    /**
     * @return \Vision\Form\AbstractCompositeType Provides a fluent interface.
     */
    public function addDecorators(array $decorators) 
    {
        foreach ($decorators as $decorator) {
            $this->addDecorator($decorator);
        }
        return $this;
    }
    
    /**
     * @return array
     */
    public function getDecorators() 
    {
        return $this->decorators;
    }
    
    /** 
     * @return \Vision\Form\AbstractCompositeType Provides a fluent interface.
     */
    public function resetDecorators()
    {
        $this->decorators = array();
        return $this;
    }
}
{'fraction_non_alphanumeric': 0.12860192102454643, 'fraction_numerical': 0.002845962290999644, 'mean_word_length': 1.7933432687531048, 'pattern_counts': {'":': 0, '<': 20, '<?xml version=': 0, '>': 50, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '5540537', 'n_tokens_mistral': 1689, 'n_tokens_neox': 1637, 'n_words': 350}