<commit_before><?php

namespace Barryvdh\Debugbar\DataCollector;

use DebugBar\DataCollector\DataCollector;
use DebugBar\DataCollector\Renderable;
use Illuminate\View\View;
class ViewCollector extends DataCollector  implements Renderable
{

    protected $views = array();

    /**
     * Add a View instance to the Collector
     *
     * @param \Illuminate\View\View $view
     */
    public function addView(View $view){
        $name = $view->getName();
        $data = array();
        foreach($view->getData() as $key => $value)
        {
            if(is_object($value) and method_exists($value, 'toArray'))
            {
                $data[$key] = $value->toArray();
            }else{
                $data[$key] = $value;
            }
        }

        $this->views[] = $name . ' => ' . $this->formatVar($data);
    }

    /**
     * Flatten a var recursively
     *
     * @param $var
     * @return mixed
     */
    public function flattenVar($var){
        if (is_array($var)) {
            foreach ($var as &$v) {
                $v = $this->flattenVar($v);
            }
        } else if (is_object($var)) {
            $var = "Object(" . get_class($var) . ")";
        }else{
            $var = htmlentities($var, ENT_QUOTES, 'UTF-8', false);
        }
        return $var;
    }

    /**
     * {@inheritDoc}
     */
    public function collect()
    {
        $views = $this->views;
        $messages = array();<commit_msg>Leave escaping upstream<commit_after><?php

namespace Barryvdh\Debugbar\DataCollector;

use DebugBar\DataCollector\DataCollector;
use DebugBar\DataCollector\Renderable;
use Illuminate\View\View;
class ViewCollector extends DataCollector  implements Renderable
{

    protected $views = array();

    /**
     * Add a View instance to the Collector
     *
     * @param \Illuminate\View\View $view
     */
    public function addView(View $view){
        $name = $view->getName();
        $data = array();
        foreach($view->getData() as $key => $value)
        {
            if(is_object($value) and method_exists($value, 'toArray'))
            {
                $data[$key] = $value->toArray();
            }else{
                $data[$key] = $value;
            }
        }

        $this->views[] = $name . ' => ' . $this->formatVar($data);
    }


    /**
     * {@inheritDoc}
     */
    public function collect()
    {
        $views = $this->views;
        $messages = array();
{'fraction_non_alphanumeric': 0.14883148831488316, 'fraction_numerical': 0.0004100041000410004, 'mean_word_length': 1.8909952606635072, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 20, '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': '2270644', 'n_tokens_mistral': 740, 'n_tokens_neox': 738, 'n_words': 154}