<commit_before><?php
namespace Aura\View\Escaper;
use Aura\View\EscaperFactory;
class Object
{
    protected $factory;
    
    protected $object;
    
    protected $quotes;
    
    protected $charset;
    
    public function __construct(EscaperFactory $factory, $object, $quotes, $charset)
    {
        $this->factory = $factory;
        $this->object  = $object;
        $this->quotes  = $quotes;
        $this->charset = $charset;
    }
    
    public function __get($key)
    {
        return $this->__escape($this->object->$key);
    }
    
    public function __call($method, $params)
    {
        return $this->__escape(call_user_func_array(
            [$this->object, $method],
            $params
        ));
    }
    
    protected function __escape($val)
    {
        if (is_string($val)) {
            // escape all actual strings
            return htmlspecialchars($val, $this->quotes, $this->charset);
        } elseif (is_array($val) || is_object($val)) {
            // wrap objects and arrays in escaper
            return $this->factory->newInstance($val);
        } else {
            // don't escape numerics, resources, bools, nulls, resources, etc.
            return $val;
        }
    }
    
    protected function __raw()
    {
        return $this->object;
    }
    
    protected function __getType()
    {
        return gettype($this->object);
    }
}<commit_msg>add __reaw() method, make __escape() public, implement ArrayAccess<commit_after><?php
namespace Aura\View\Escaper;
use Aura\View\EscaperFactory;
class Object implements \ArrayAccess
{
    protected $factory;
    
    protected $object;
    
    protected $quotes;
    
    protected $charset;
    
    public function __construct(EscaperFactory $factory, $object, $quotes, $charset)
    {
        $this->factory = $factory;
        $this->object  = $object;
        $this->quotes  = $quotes;
        $this->charset = $charset;
    }
    
    public function __get($prop)
    {
        return $this->__escape($this->object->$prop);
    }
    
    public function __call($method, $params)
    {
        return $this->__escape(call_user_func_array(
            [$this->object, $method],
            $params
        ));
    }
    
    public function __raw()
    {
        return $this->object;
    }
    
    public function __escape($spec)
    {
        if (is_string($spec)) {
            // escape all actual strings
            return htmlspecialchars($spec, $this->quotes, $this->charset);
        } elseif (is_array($spec) || is_object($spec)) {
            // wrap objects and arrays in escaper
            return $this->factory->newInstance($spec);
        } else {
            // don't escape numerics, resources, bools, nulls, resources, etc.
            return $spec;
        }
    }
    
    /**
     * 
     * ArrayAccess: does the requested property exist?
     * 
     * @param string $prop The requested property.
     * 
     * @return bool
     * 
     */
    public function offsetExists($prop)
    {
        return isset($this->object->$prop);
    }
    
    /**
     * 
     * ArrayAccess: get a property value.
     * 
     * @param string $prop The requested property.
     * 
     * @return mixed
     * 
     */
    public function offsetGet($prop)
    {
        return $this->__escape($this->object->$prop);
    }
    
    /**
     * 
     * ArrayAccess: set a property value.
     * 
     * @param string $prop The requested property.
     * 
     * @param mixed $spec The value to set it to.
     * 
     * @return void
     * 
     */
    public function offsetSet($prop, $spec)
    {
        $this->object->$prop = $spec;
    }
    
    /**
     * 
     * ArrayAccess: unset a property.
     * 
     * @param string $prop The requested property.
     * 
     * @return void
     * 
     */
    public function offsetUnset($prop)
    {
        unset($this->object->$prop);
    }
}
{'fraction_non_alphanumeric': 0.12506393861892584, 'fraction_numerical': 0.0, 'mean_word_length': 1.8136690647482014, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 41, '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': '3846154', 'n_tokens_mistral': 1182, 'n_tokens_neox': 1151, 'n_words': 263}